Bug #21983


Thumbnail generation broken for PDF files

Added by Online Now! GmbH over 14 years ago. Updated almost 14 years ago.

Must have
Target version:
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:


Due the patch with report 0012341, the generation of thumbnails for PDF files does not work anymore. The problem is the missing frame parameter in the GraphicsMagick call.

The following line was added in the function imageMagickExec ( t3lib/class.t3lib_stdgraphic.php):

$frame = $frame ? '['.intval($frame).']' : '';

This means the frame parameter will not be added, if the frame number is 0 or empty. This is a problem for PDF files, causing GraphicsMagick to hang and creating an image for each page of the PDF.

In previous version, the frame parameter was alyway added to the GM command, even for normal images. So a fix for this problem, could be changing the line to:

$frame = '['.intval($frame).']';

Problem occurs in 4.3.1 as well.
(issue imported from #M13283)


13283.patch (1.1 KB) 13283.patch Administrator Admin, 2010-01-18 17:16
13283_v2.patch (1.1 KB) 13283_v2.patch Administrator Admin, 2010-01-18 18:12
13283_v6.patch (2.01 KB) 13283_v6.patch Administrator Admin, 2010-02-21 20:09
13283_v7.patch (2.05 KB) 13283_v7.patch Administrator Admin, 2010-02-22 09:42
bug_13283_v9.diff (1.69 KB) bug_13283_v9.diff Administrator Admin, 2010-03-06 00:06

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #21360: Image Generation broken with PHP safe_mode = On / GraphicsmagickClosedBenni Mack2009-10-26

Has duplicate TYPO3 Core - Bug #22360: Thumbnails generation on some pdfClosedSteffen Gebert2010-03-31

Has duplicate TYPO3 Core - Bug #22488: Content element "Filelink" does not create PDF thumbnailsClosedChristian Kuhn2010-04-20

Actions #1

Updated by Florian Schaeffer over 14 years ago

or even better

$frame = $this->noFramePrepended?'':'['.intval($frame).']';

as in imageMagiskIdentify()

Actions #2

Updated by Benni Mack over 14 years ago

Hey Florian,

see if the patch works for you.

Actions #3

Updated by Online Now! GmbH over 14 years ago

v2 Patch works for me, but i didnt test with setting 'noFramePrepended' enabled.

Actions #4

Updated by Florian Schaeffer over 14 years ago

v2 Patch works fine for me as long as I don't set noFramePrepended = 1.

If I do, the server converts all pages of the PDF but fails to finally create the picture without any pagenumber appended.

So +1 for using this patch for GM with noFramePrepended=0 but I think there is still something wrong in parsing and generating PDF file thumbnails

Actions #5

Updated by André Steiling over 14 years ago

v2 patch is working in 4.3.1 as well as long I don't set noFramePrepended = 1.

Actions #6

Updated by Andy Grunwald over 14 years ago


i can confirm this bug, too.

The request is, to render the first page of a multisite pdf as image.

"13283_v2.patch" works for me with the following setup:

OS: Debian Lenny
TYPO3 4.2.11
PHP 5.2.6-1+lenny3
GraphicsMagick 1.1.11 2008-02-23 Q8
im_noFramePrepended: 0

OS: Debian Lenny
TYPO3 4.2.11
PHP 5.2.6-1+lenny3
ImageMagick 6.3.7 08/09/09 Q16
im_noFramePrepended: 0

If i changed im_noFramePrepended to 1, filenames like f5f1b664b1.jpg.0 and f5f1b664b1.jpg.1 will be created in typo3temp and the image couldn`t be found.

Perhaps a check, if $output.'.0' is existing, if yes, remove ".0" from filename is a solution?
I think this is a "dirty" solution.

Actions #7

Updated by Claus Fassing over 14 years ago

This is the default behavior of convert (gs). If input file a multipage and no frame is given, convert will append the scene number. The scene number can formatted by printf function something like this.
$output = t3lib_div::split_fileref($output);
$output = $output['path'].$output['filebody'].'%02d.'.$output['fileext'];

In addition, not only thumbnails are affected. This break the output rendering of pdf to jpg also.
Reproduce : Just put a pdf file into image ce result in empty output.

Actions #8

Updated by Lukas Vorlicek over 14 years ago

Same problem here...

TYPO3 4.3.1, CentOS 5.4, GM 1.3.8, PHP 5.2.8

v2 patch works, but with noFramePrepended = 0 only...

Actions #9

Updated by Benni Mack over 14 years ago

v6 takes care of noFramePrepended for PDFs. It's in the core list. Please give your votes (+1 after reading or testing, whatever you do), in there so we can get this in 4.3.2.

Actions #10

Updated by Florian Schaeffer over 14 years ago

Hi Benni,

thanks for your efforts. I tried your patch at it isn't working...

If I echo the resulting command I get
"/usr/local/bin/gm convert +profile \'*\' -geometry 159x159! -colorspace RGB -quality 90 'uploads/media/moodbild-eh-intranet.jpg'[0]'typo3temp/pics/e139ec7e59.jpg'"

due to the line
$this->wrapFileName($input) . $frame

the filename gets wrapped and then the frame is appended and then I think there is a missing blank between input and output ... the resulting command is not valid and so the preview picture is not generated...

I had to change the line to
$cmd = t3lib_div::imageMagickCommand('convert', $params . ' ' . $this->wrapFileName($input . $frame) . ' ' . $this->wrapFileName($output));

now it works for me with and without noFramePrepended

Actions #11

Updated by Claus Fassing over 14 years ago

if a PDF is used as the input file, a frame number must always be added
to select the first page of the PDF

Bad design. I use this method as interface to convert multipage pdf files into images. This will not work anymore

$frame should be already a part from $input given from method call

Actions #12

Updated by Benni Mack over 14 years ago

Hello Claus.

Well, tell this to the guys who introduced the new "wrapFIle" function that escapes all [] and thus make the generation not work at all. See #0012341 for more details.

Also, attached is a new patch (from Steffen Ritter) that fixes one spaces problem.

Actions #13

Updated by Florian Schaeffer over 14 years ago

Hello Benni,

perfect, v7 works.

also got my +1 on core list

Actions #14

Updated by Steffen Ritter over 14 years ago

@ Claus, you can select further PDF-Pages. The Frame Parameter will be used...
You just have to do it manually. From Extension: No Problem.
From GifBuilder or so on: Always first page.

Actions #15

Updated by Claus Fassing over 14 years ago

Not really, cause I do not know the number of pages of incoming pdf files, which i need to call the imageMagickExec function looping with each one frame number.
In fact there is a IM/GM method to detect this but this will result in additional load.
No, i guess i will make a clone of imageMagickExec function that does what the name suggested.

Actions #16

Updated by Kay Strobach over 14 years ago

will pdf thumbnail creation work in typo3 4.4.0 or 4.3.3??

I took my quite i while to understand, why there was such a great change in functionality just in a service release ...

The main problem is, that the thumb creation in the backend works fine!

Thanks for your work, but please make it work like in 4.3.0!

Best regards


Actions #17

Updated by Steffen Ritter over 14 years ago

@Kay Wienöbst
it will for 4.3 as soon as another core Dev is reviewing the patch, wie lack one further core-vote.

Actions #18

Updated by Oliver Hader over 14 years ago

Committed to SVN:
  • TYPO3_4-2 (rev. 7104)
  • TYPO3_4-3 (rev. 7105)
  • Trunk (rev. 7106)

Thanks to Andreas Beutel from the company "mehrwert" ( for sponsoring this bug at the T3BOARD10's bug auction!


Also available in: Atom PDF