private function compile()
    {
        $commands = array_keys($this->commands);
        $values = $this->getArrayValues(array_values($this->commands));

        $origSource = $this->source;

        $vs = '%s';
        $bin = $this->converter;
        $type = preg_replace('#^image/#', null, $this->getInfo('type'));

        $this->tmpFile = $this->getTempFile();

        if ($this->isMultipartImage()) {

            $this->intermediate = $this->getTempFile($type);
            $this->source = $this->intermediate;

        }

        array_unshift($values, sprintf('%s:%s', $type, escapeshellarg($this->source)));

        array_unshift($values, $bin);

        array_unshift($commands, $vs);
        array_unshift($commands, $vs);

        if ($this->isMultipartImage()) {

            array_unshift(
                $values,
                sprintf(
                    '%s %s:%s -coalesce %s %s',
                    $this->converter,
                    $type,
                    $origSource,
                    $this->intermediate,
                    PHP_EOL
                )
            );
            array_unshift($commands, $vs);
        }

        array_push($values, sprintf('%s:%s', $this->getOutputType(), $this->tmpFile));
        array_push($commands, $vs);

        $cmd = implode(' ', $commands);

        $this->source = $origSource;

        return vsprintf($cmd, $values);
    }