// Path: xvfb-manager/src/main/java/com/github/mike10004/xvfbmanager/Screenshot.java
// class FileByteSource extends ByteSource {
// 
//     public final File file;
//     private final ByteSource delegate;
// 
//     public FileByteSource(File file) {
//         this(file, Files.asByteSource(file));
//     }
// 
//     protected FileByteSource(File file, ByteSource delegate) {
//         this.file = checkNotNull(file);
//         this.delegate = checkNotNull(delegate);
//     }
// 
//     @Override
//     public CharSource asCharSource(Charset charset) {
//         return delegate.asCharSource(charset);
//     }
// 
//     @Override
//     public InputStream openStream() throws IOException {
//         return delegate.openStream();
//     }
// 
//     @Override
//     public InputStream openBufferedStream() throws IOException {
//         return delegate.openBufferedStream();
//     }
// 
//     @Override
//     public ByteSource slice(long offset, long length) {
//         return delegate.slice(offset, length);
//     }
// 
//     @Override
//     public boolean isEmpty() throws IOException {
//         return delegate.isEmpty();
//     }
// 
//     @SuppressWarnings("Guava")
//     @Override
//     @Beta
//     public com.google.common.base.Optional<Long> sizeIfKnown() {
//         return delegate.sizeIfKnown();
//     }
// 
//     @Override
//     public long size() throws IOException {
//         return delegate.size();
//     }
// 
//     @Override
//     public long copyTo(OutputStream output) throws IOException {
//         return delegate.copyTo(output);
//     }
// 
//     @Override
//     public long copyTo(ByteSink sink) throws IOException {
//         return delegate.copyTo(sink);
//     }
// 
//     @Override
//     public byte[] read() throws IOException {
//         return delegate.read();
//     }
// 
//     @Override
//     @Beta
//     public <T> T read(ByteProcessor<T> processor) throws IOException {
//         return delegate.read(processor);
//     }
// 
//     @Override
//     public HashCode hash(HashFunction hashFunction) throws IOException {
//         return delegate.hash(hashFunction);
//     }
// 
//     @Override
//     public boolean contentEquals(ByteSource other) throws IOException {
//         return delegate.contentEquals(other);
//     }
// }


import io.github.mike10004.subprocess.ProcessMonitor;
import io.github.mike10004.subprocess.ProcessResult;
import io.github.mike10004.subprocess.ProcessTracker;
import io.github.mike10004.subprocess.Subprocess;
import com.github.mike10004.xvfbmanager.Screenshot.FileByteSource;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.ByteSource;
import com.google.common.io.Files;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.requireNonNull;
        this.processTracker = requireNonNull(processTracker);
    }

    @Override
    public ImageioReadableScreenshot convert(Screenshot source) throws IOException, XvfbException {
        File pnmFile = File.createTempFile("xwdtopnm-stdout", ".ppm", tempDir.toFile());
        try {
            return convert(source, pnmFile);
        } finally {
            if (!pnmFile.delete()) {
                log.info("failed to delete {}", pnmFile);
            }
        }
    }

    protected ImageioReadableScreenshot convert(Screenshot source, File pnmFile) throws IOException, XvfbException {
        File stderrFile = File.createTempFile("xwdtopnm-stderr", ".txt", tempDir.toFile());
        try {
            return convert(source, pnmFile, stderrFile);
        } finally {
            if (!stderrFile.delete()) {
                log.info("failed to delete {}", stderrFile);
            }
        }
    }

    public ImageioReadableScreenshot convert(Screenshot source, File pnmFile, File stderrFile) throws IOException, XvfbException {
        final File inputFile;
        final boolean deleteInputFile;
        ByteSource inputSource = source.asByteSource();
// Path: xvfb-manager/src/main/java/com/github/mike10004/xvfbmanager/Screenshot.java
// class FileByteSource extends ByteSource {
// 
//     public final File file;
//     private final ByteSource delegate;
// 
//     public FileByteSource(File file) {
//         this(file, Files.asByteSource(file));
//     }
// 
//     protected FileByteSource(File file, ByteSource delegate) {
//         this.file = checkNotNull(file);
//         this.delegate = checkNotNull(delegate);
//     }
// 
//     @Override
//     public CharSource asCharSource(Charset charset) {
//         return delegate.asCharSource(charset);
//     }
// 
//     @Override
//     public InputStream openStream() throws IOException {
//         return delegate.openStream();
//     }
// 
//     @Override
//     public InputStream openBufferedStream() throws IOException {
//         return delegate.openBufferedStream();
//     }
// 
//     @Override
//     public ByteSource slice(long offset, long length) {
//         return delegate.slice(offset, length);
//     }
// 
//     @Override
//     public boolean isEmpty() throws IOException {
//         return delegate.isEmpty();
//     }
// 
//     @SuppressWarnings("Guava")
//     @Override
//     @Beta
//     public com.google.common.base.Optional<Long> sizeIfKnown() {
//         return delegate.sizeIfKnown();
//     }
// 
//     @Override
//     public long size() throws IOException {
//         return delegate.size();
//     }
// 
//     @Override
//     public long copyTo(OutputStream output) throws IOException {
//         return delegate.copyTo(output);
//     }
// 
//     @Override
//     public long copyTo(ByteSink sink) throws IOException {
//         return delegate.copyTo(sink);
//     }
// 
//     @Override
//     public byte[] read() throws IOException {
//         return delegate.read();
//     }
// 
//     @Override
//     @Beta
//     public <T> T read(ByteProcessor<T> processor) throws IOException {
//         return delegate.read(processor);
//     }
// 
//     @Override
//     public HashCode hash(HashFunction hashFunction) throws IOException {
//         return delegate.hash(hashFunction);
//     }
// 
//     @Override
//     public boolean contentEquals(ByteSource other) throws IOException {
//         return delegate.contentEquals(other);
//     }
// }


// Path: xvfb-manager/src/main/java/com/github/mike10004/xvfbmanager/XwdFileToPngConverter.java
import io.github.mike10004.subprocess.ProcessMonitor;
import io.github.mike10004.subprocess.ProcessResult;
import io.github.mike10004.subprocess.ProcessTracker;
import io.github.mike10004.subprocess.Subprocess;
import com.github.mike10004.xvfbmanager.Screenshot.FileByteSource;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.ByteSource;
import com.google.common.io.Files;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.requireNonNull;

        this.processTracker = requireNonNull(processTracker);
    }

    @Override
    public ImageioReadableScreenshot convert(Screenshot source) throws IOException, XvfbException {
        File pnmFile = File.createTempFile("xwdtopnm-stdout", ".ppm", tempDir.toFile());
        try {
            return convert(source, pnmFile);
        } finally {
            if (!pnmFile.delete()) {
                log.info("failed to delete {}", pnmFile);
            }
        }
    }

    protected ImageioReadableScreenshot convert(Screenshot source, File pnmFile) throws IOException, XvfbException {
        File stderrFile = File.createTempFile("xwdtopnm-stderr", ".txt", tempDir.toFile());
        try {
            return convert(source, pnmFile, stderrFile);
        } finally {
            if (!stderrFile.delete()) {
                log.info("failed to delete {}", stderrFile);
            }
        }
    }

    public ImageioReadableScreenshot convert(Screenshot source, File pnmFile, File stderrFile) throws IOException, XvfbException {
        final File inputFile;
        final boolean deleteInputFile;
        ByteSource inputSource = source.asByteSource();
        if (inputSource instanceof FileByteSource) {