The command runs perfectly via the CLI (see shell.png), but when run in PHP it outputs a completely different image (see php.jpg). php.jpg was originally named php.png as it was the file being outputted when the command was run via PHP, however when uploading the image as an attachment for this post the uploader told me that “This JPEG image has the incorrect file extension” - this would suggest that the mime type of the file that the convert command is outputting when run via PHP is image/jpeg? If I take the ‘-background transparent’ switch out of the command it runs the same in PHP as on the CLI, but I have no idea why!
Here’s what the command is supposed to achieve:
Set the format of the image that will be outputted to a 32-bit PNG with a transparent background
Resize the image to an appropriate size and then crop it from the center of the image
Rotate the image -4.4 degrees
The result of the command should then be output to a PNG file
The 2>&1 is simply a redirection of stderr to the same location as stdout so that I can capture any error in PHP
On my local development setup (MAMP on OS X Leopard) I am running ImageMagick 6.3.6 11/28/07 Q8 (on the live server the version of ImageMagick is 6.0.7 05/03/07 Q16, so I’m expecting functionality to be pretty similar?)
I’m open of course to any suggestions that use a different ImageMagick method to achieve the results I require - any help is greatly appreciated as this has been baffling me for a good while now, thanks!
Thanks for the information Rubble, that’s definitely useful to know, however the problem I’m getting is when testing with my local development setup (newer version of ImageMagick). The key part of my problem is that I can’t seem to output a PNG with an alpha transparent background - I’ve tried several different approaches, but I’ve found the ImageMagick documentation regarding transparency and PNGs to be rather confusing!
Note if I use -resize \“440x<\” it works but if I use -resize ‘440x<’ it fails. This is just something to do with windows.
Version: ImageMagick 6.3.7 11/14/07 Q16
I can use either on my server and they work Version: ImageMagick 6.3.5 08/29/07 Q16
I have had nothing to do with OS X and presume it must be something similar with the way the code is written ?
P.S. If I use the XP command line I must use -resize “440x<” not -resize ‘440x<’ as well.