Index: t3lib/class.t3lib_stdgraphic.php =================================================================== --- t3lib/class.t3lib_stdgraphic.php (Revision 6947) +++ t3lib/class.t3lib_stdgraphic.php (Arbeitskopie) @@ -2657,13 +2657,28 @@ * @param string The relative (to PATH_site) image filepath, input file (read from) * @param string The relative (to PATH_site) image filepath, output filename (written to) * @param string ImageMagick parameters - * @param string Refers to which frame-number to select in the image. '' or 0 will select the first frame, 1 will select the next and so on... + * @param int Optional, Refers to which frame number to select in the image, starting with + * "0" as the first frame. If no frame number is given, the parameter is omitted. + * If a PDF is used as input file and no frame is used, it will always set the frame parameter + * * @return string The result of a call to PHP function "exec()" */ - function imageMagickExec($input,$output,$params,$frame = 0) { - if (!$this->NO_IMAGE_MAGICK) { - $frame = $frame ? '['.intval($frame).']' : ''; - $cmd = t3lib_div::imageMagickCommand('convert', $params.' '.$this->wrapFileName($input).$frame.' '.$this->wrapFileName($output)); + function imageMagickExec($input, $output, $params, $frame = -1) { + if (!$this->NO_IMAGE_MAGICK) { + + $frame = intval($frame); + // if a PDF is used as the input file, a frame number must always be added + // to select the first page of the PDF + if (strtolower(substr($input,-3)) == 'pdf') { + $frame = '[' . ($frame > 0 ? $frame : '0') . '] '; + // add the frame number only if there is a frame used (starting by frame 0), add the frame + } else if (!$this->noFramePrepended && $frame >= 0) { + $frame = '[' . $frame . '] '; + } else { + $frame = ' '; + } + + $cmd = t3lib_div::imageMagickCommand('convert', $params . ' ' . $this->wrapFileName($input) . $frame . $this->wrapFileName($output)); $this->IM_commands[] = array($output,$cmd); $ret = exec($cmd);