I'm using ImageMagick to convert a RAW file (*.nef extension) into a JPEG image. I'm actually doing this from within PHP, but not using the IMagick extension (I spent too much time banging my head against a wall trying to get that working that eventually I just gave up). Instead, I'm using PHP's exec()
function to call ImageMagick from the command line and just do the manipulations there.
Anyways, I wrote a simple PHP script to do this -- to convert the NEF image into a JPEG image -- and it worked! I ran it through a number of tests. When the JPEG didn't exist, it created it. When the JPEG already did exist, it overwrote it. Perfect!
Until today. I made that script last Friday. Today (Monday), when it tried to use it, it stopped working. I literally changed nothing about it,开发者_Python百科 but a couple days later it's failing all the same tests that I ran on Friday. I can retrieve the output from the command line, and these are the errors it's encountering this time around:
Magick: `%s' (%d) dcraw.exe -4 -w -O "C:/Windows/TEMP/magick-iDvVnHw-.ppm" "C:/Windows/TEMP/magick-hYeYwWRd" @ error/utility.c/SystemCommand/2094.
Magick: delegate failed `dcraw.exe -4 -w -O "%u.ppm" "%i"' @ error/delegate.c/InvokeDelegate/1058.
Magick: unable to open image `C:/Windows/TEMP/magick-iDvVnHw-.ppm': No such file or directory @ error/blob.c/OpenBlob/2588.
Magick: missing an image filename `E:\test.jpg' @ error/convert.c/ConvertImageCommand/3015.
These errors didn't show up on Friday. Why are they showing up now? What do they mean? And what can I do about them? Thanks in advance.
I had a similar error on linux:
No such file or directory @ error/blob.c/OpenBlob/2709. convert: no images defined `/tmp/transform_5c88983-1.jpg' @ error/convert.c/ConvertImageComman
The problem was a special character in my german picturename:
images/1/14/Ministerium-für-Bildung.jpg
I went into the folder and created a symlink without the character:
ln -s Ministerium-für-Bildung.jpg Ministerium-fr-Bildung.jpg
Well, I was able to solve it. I did two things, and I'm not entirely sure that the first thing had any impact or not, but I'll mention both for anyone else struggling. First, since it seemed to be having trouble with a temp file, I changed the Windows security/permissions on the C:\Windows\TEMP
folder to explicitly allow IIS_USER
full control, as well as Everyone
.
But secondly, and more importantly, I changed the command I was passing into exec()
. Previously my command looked something like this:
$cmd = 'C: & "C:\\Program Files (x86)\\ImageMagick\\convert.exe" ';
$cmd .= '"E:\\test.nef" "E:\\test.jpg" 2>&1';
exec($cmd, $output, $return);
So instead I specified a new "temp" directory, and set the current path, like so:
$cmd = 'SET MAGICK_TMPDIR=E:\\Temp&SET path=C:\\Program Files (x86)\\;%path%& ';
$cmd .= '"C:\\Program Files (x86)\\ImageMagick\\convert.exe" ';
$cmd .= '"E:\\test.nef" "E:\\test.jpg" 2>&1';
exec($cmd, $output, $return);
And that did the trick! The script is working again.
精彩评论