Project

General

Profile

Actions

Bug #18499

closed

Typo in t3lib/thumbs.php causes eternally lasting gm processes to slow down server.

Added by Michiel Roos over 16 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2008-03-26
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.2
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Affects all versions.

Steps to reproduce problem:
- setup a TYPO3 with GraphicsMagick
- Upload a file with a space in the name
- go to the fileadmin
- try to generate a thumbnail
- watch the output of a: ps ax on the console

For an unknown (to me at least) reason the 'convert sample' command in t3lib/thumbs.php states:
$parameters = '-sample '.$this
>size.' '.$colors.' '.$this->wrapFileName($this->input.'[0]').' '.$this->wrapFileName($this->output);

Where this should read:
$parameters = '-sample '.$this->size.' '.$colors.' '.$this->wrapFileName($this->input).' '.$this->wrapFileName($this->output);

Note the ommission of .'[0]' . . . It is unclear to me why it is there . . .

It causes the call to wrapFileName 'not' to wrap a filename with spaces and thus spawns a faulty gm conversion command (unquoted filename with spaces) which hangs around on the server in the process queue untill killed manually.

I cannot find any reference to a [0] in any documentation on ImageMagick / GraphicsMagich and thus think this is a typo.

Removing .[0] from the code results in happy thumbnail generation.

(issue imported from #M7938)


Files

graph_image.png (36.9 KB) graph_image.png Administrator Admin, 2008-04-04 15:11
Actions #1

Updated by Michiel Roos over 16 years ago

Hi again,

I did some more digging in the dirt (after the server slowed down again, trying to churn through several rubbish gm commands . . .

Failing gm example commands (as snipped from ps output):
gm convert -geometry 240x161! -colors 64 fileadmin/10th_anniversary/Memorial Anniversary 002.png\[0\] typo3temp/pics/a733efa5c4.png
gm convert -geometry 110x74! -colors 64 fileadmin/10th_anniversary/Memorial Anniversary 002_600px.png\[0\] typo3temp/pics/1cd7a9a68c.png
gm convert -geometry 110x74! -colorspace RGB -quality 70 fileadmin/10th_anniversary/Memorial Anniversary 002_600px.jpg\[0\] typo3temp/pics/65180b628c.jpg

http://www.imagemagick.org/script/command-line-processing.php

The use of [0] in thumbs.php is to select the first frame of a multiframe image. Usage of this parameter should be controlled by:

$TYPO3_CONF_VARS['GFX']['im_noFramePrepended']
Boolean. If set, the [x] frame indicator is NOT prepended to filenames in stdgraphic. Some IM5+ version didn't work at all with the typical [0]-prefix, which allow multipage pdf's and animated gif's to be scaled only for the first frame/page and that seriously cuts down rendering time. Set this flag only if your ImageMagick version cannot find the files. Notice that changing this flag causes temporary filenames to change, thus the server will begin scaling images again which were previously cached.

The correct usage of the frame parameter (since *nix interprets the brackets as shell commands) is:
- convert 'images.gif0' image.png
- convert 'images.gif[0-4]' images.mng
- convert 'images.gif[3,2,4]' images.mng

Also valid are:
- convert 'i m a ges.gif0' image.png
- convert 'i m a ges.gif[0-4]' images.mng
- convert 'i m a ges.gif[3,2,4]' images.mng

As are:
- convert "i m a ges.gif0" image.png
- convert "i m a ges.gif[0-4]" images.mng
- convert "i m a ges.gif[3,2,4]" images.mng

Frames should work for both IM and GM: http://www.simplesystems.org/RMagick/doc/imusage.html

phew

:-)

So the [0] in the thumbs.php is good for something after all. It is also in the right place (inside the call to wrapFileName).

It is however not dependant on the value of $TYPO3_CONF_VARS['GFX']['im_noFramePrepended']

Note that this impies that the function imageMagickIdentify() in t3lib/class.t3lib_stdgraphic.php does NOT correctly use the frame (places it outslide of the quotes):
$cmd = t3lib_div::imageMagickCommand('identify', $this->wrapFileName($imagefile).$frame);

time passes

After debugging with a nice large and wide errorGif . . . it turns out that the actual $cmd passed to exec() looks fine and dandy!

But: http://nl2.php.net/manual/en/function.exec.php reads:
'With safe mode enabled, the command string is escaped with escapeshellcmd(). Thus, echo y | echo x becomes echo y \| echo x.'

. . . and . . . thus . . . it comes out . . . unquoted . . . looking like:
- convert i m a ges.gif\[0\] image.png
- convert i m a ges.gif\[0-4\] images.mng
- convert i m a ges.gif\[3,2,4\] images.mng

But why unquoted?

Actions #2

Updated by Michiel Roos over 16 years ago

What baffles me most . . . is that when you do leave off the [0] in thumbs.php . . . the image (with spaces in the name) gets generated fine.

But I can't see clearly any more . . . please can someone with a fresh brain look into this?

Cheers!

Actions #3

Updated by Michiel Roos over 16 years ago

Furthermore . . .

some pdf's generate a 'hanging process' . . . .

/var/www/php/safe_mode_exec/gm convert -geometry 106x150! -colorspace RGB -quality 70 fileadmin/some.pdf typo3temp/some.jpg

  • Warning: Fonts with Subtype = /TrueType should be embedded.
    The following fonts were not embedded:
    ArialMT
    CourierNewPSMT
    TimesNewRomanPS-BoldMT
    TimesNewRomanPSMT
    Verdana
    Verdana-Bold
    Verdana-BoldItalic
    Verdana-Italic
  • This file had errors that were repaired or ignored.
  • The file was produced by:
  • >>>> Acrobat Distiller 7.0.5 (Windows) <<<<
  • Please notify the author of the software that produced this
  • file that it does not conform to Adobe's published PDF
  • specification.
  • glibc detected * double free or corruption (!prev): 0x000000000078e7a0 *

process never returns . . . .

ImageMagick will return (failing though, but not crashing) . . .

I think I'll switch back to ImageMagick for now . . . .

Actions #4

Updated by Michiel Roos over 16 years ago

Added a 'before' and 'after' GraphicsMagick picture . . .

;-)

Actions #5

Updated by Steffen Gebert over 14 years ago

Is this still valid? It's the same problem as #21983, but on a different place, I think.

Actions #6

Updated by Steffen Gebert over 14 years ago

The line is currently

$parameters = '-sample ' . $this->size . ' ' . $this->wrapFileName($this->input) . '[0] ' . $this->wrapFileName($this->output);

The [0] is not passed to wrapFileName() and though not escaped, that's why I think this problem is fixed.

Actions #7

Updated by Michiel Roos over 14 years ago

I'll have to check on a recent Debian system with gm and a TYPO3 4.3 version.

Actions #8

Updated by Michiel Roos over 14 years ago

Just uploaded a pdf with a space in the name to a TYPO3 4.3.3 using gm for thumbnailing.

The thumb generates fine. I think this issue can be closed.

GM seems to be a lot faster than im.

Thanks Steffen.

Actions #9

Updated by Steffen Gebert over 14 years ago

Thanks for your feedback, Michiel!

Actions #10

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF