Project

General

Profile

Actions

Bug #24931

closed

Quoting of path and filename in ImageMagick/GraphicsMagick not working on Windows + PHP5.2

Added by Jörg Wagner over 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Communication
Target version:
-
Start date:
2011-02-02
Due date:
% Done:

0%

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

Description

Quoting of the path and filename of the ImageMagick/GraphicsMagick executable has been introduced with 4.4.5. Here is an example:

4.4.4:
C:\Programme\GraphicsMagick-1.3.7-Q8/gm.exe convert -geometry 50x50! "uploads/pics/myimage.gif[0]" "typo3temp/pics/f58c0b5193.gif"

4.4.5:
"C:/Programme/GraphicsMagick-1.3.7-Q8/gm.exe" convert +profile '*' -geometry 50x50! "uploads/pics/myimage.gif"[0] "typo3temp/pics/f58c0b5193.gif"

Both of these commands will work, if executed directly on the Windows command line. But the 4.4.5 version will fail when executed through the PHP exec() command on Windows <b>with PHP versions below 5.3</b>.
For the exec() command of PHP >=5.3 both commands will work nicely.

<b>Explanation for PHP < 5.3:</b>
The quoting of the IM/GM executable path and filename in the complete command line requires the whole string to be quoted a second time, to make it work with exec() on Windows. Details can be found in the posting of "luko post cz", 30-Jan-2008 02:15, on http://php.net/manual/en/ref.exec.php

The working version for 4.4.5 must look like this:

""C:/Programme/GraphicsMagick-1.3.7-Q8/gm.exe" convert +profile '*' -geometry 50x50! "uploads/pics/myimage.gif"[0] "typo3temp/pics/f58c0b5193.gif""

<b>Explanation for PHP >=5.3:</b>
The PHP 5.3.0 change log (http://php.net/ChangeLog-5.php) contains a hint that the exec() behavior has been changed:

Version 5.3.0
30-June-2009
...
Fixed exec() on Windows to not eat the first and last double quotes. (Scott)

<b>Bottom line</b>
Quoting twice is the way to go on Windows, but is needed and working only for PHP versions below 5.3 on Windows. For PHP >=5.3 this is NOT needed and actually results in an error!

The attached patches for TYPO3 4.4.5 and TYPO3 4.5.0 will correct the problem with all PHP 5 versions on Windows.

(issue imported from #M17447)


Files

17447_JW_v1_4.4.5.diff (325 Bytes) 17447_JW_v1_4.4.5.diff Administrator Admin, 2011-02-02 13:43
17447_JW_v1_4.5.0.diff (371 Bytes) 17447_JW_v1_4.5.0.diff Administrator Admin, 2011-02-02 13:43

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #22243: Several GIFBUILDER features broken for IM6 and GMClosedJigal van Hemert2010-03-05

Actions
Is duplicate of TYPO3 Core - Bug #24281: ImageMagick does not work with quotes in exec() path on WindowsClosedJigal van Hemert2010-12-03

Actions
Actions #1

Updated by Jörg Wagner over 13 years ago

This report should be marked as child of #0013750.

Actions #2

Updated by Jigal van Hemert about 13 years ago

Solution in 16656 also works. Both solutions have the same problem: they won't work with safe_mode enabled.

Maybe the best possible solution is to only use quotes if it is really necessary and to only use a dummy command (or extra quotes) if the command begins and ends with a quote && PHP <5.3 && OS==win
This won't work in all circumstances, but it increases the number of installations where it will work. Maybe we should log a warning in cases which are known not to work

Actions #3

Updated by Markus Kappe about 13 years ago

Additional info: http://de.php.net/manual/en/function.exec.php#198369

The patch should be placed in t3lib_utility_Command::exec()

Actions #4

Updated by Jigal van Hemert about 13 years ago

solved in #24281, so this one can be closed as duplicate

Actions

Also available in: Atom PDF