Batch convert and errors logging

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
al3x

Batch convert and errors logging

Post by al3x »

Hi,

I'm using imageMagick to convert a bunch of files. I'm Using :

Code: Select all

mogrify -format png ~/SRCS/*.jpg 
As I'm using the Lasso language (a kind of PHP like) I would like to log if errors occur to handle them. What is the best way to do it ? I tried to add -debug with no success

Thank you for your help !
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Batch convert and errors logging

Post by snibgo »

Like most command-line software, IM writes errors to stderr. You can use a shell facility to redirect this to a file, something like:

mogrify -format png ~/SRCS/*.jpg 2>error.lis
snibgo's IM pages: im.snibgo.com
al3x

Re: Batch convert and errors logging

Post by al3x »

Sounds good, thank you !
pjvedder
Posts: 12
Joined: 2011-06-22T12:39:02-07:00
Authentication code: 8675308

Re: Batch convert and errors logging

Post by pjvedder »

Does anyone know if there is something similar for ColdFusion? I'm using cfexecute to call ImageMagick, and for the life of me, I can't get it to output to the screen or a logfile for anything other than the identify command. If I try the same code that shows the details of the image from "identify", it doesn't work for convert. I've tried to add -debug "All", and even the method you suggested above (2>error.txt). I've also tried to add a <cfsavecontent> around the cfexecute, and add both a variable and output file option to the cfexecute. Nothing seems to be working.

My main problem is that if for some reason ImageMagick errors, I'll have no way of knowing in Coldfusion, aside from the fact that the image will never get converted. Does anyone have any suggestions? Thanks in advance.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch convert and errors logging

Post by fmw42 »

don't know if this will help, but see -regard-warnings at http://www.imagemagick.org/Usage/basics/#controls

convert inputimage -regard-warnings outputimage || echo "bad image"
pjvedder
Posts: 12
Joined: 2011-06-22T12:39:02-07:00
Authentication code: 8675308

Re: Batch convert and errors logging

Post by pjvedder »

Cool, thanks. That definitely pointed me in the right direction. The only problem was that I needed to add -verbose to it in order for anything to show up on the screen. It looks like -report-warnings is stopping for problems that I don't want it to stop for, though, and images that once came out fine, are now reporting errors. Getting there.. slowly but surely....
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Batch convert and errors logging

Post by Bonzo »

In php exec() will not display the output on the screen but system() will. They do the same otherwise; do you have anything similar in Lasso ?
pjvedder
Posts: 12
Joined: 2011-06-22T12:39:02-07:00
Authentication code: 8675308

Re: Batch convert and errors logging

Post by pjvedder »

So after some more testing, I realized yet another problem with ColdFusion. When I run the below command in an actual command line, I get the following results:

Command Line:
C:\Program Files\ImageMagick-6.7.0-Q16>convert -verbose C:\websites\backend\tasks\cmr\img\44230_460V_07.eps -regard-warnings C:\websites\backend\tasks\cmr\img-res\44230_460V_07.jpg || echo "bad image"
Results:
[ghostscript library] Files/gs/gs9.02/bin/gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r457x457" -g3085x4113 "-sOutputFile=C:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-uvAX8gz_-%08d" "-fC:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-LfYQlzJx""-fC:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-J9RqqMNO"C:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-uvAX8gz_-00000001 PAM 3085x4113 3085x4113+0+0 8-bit ColorSeparation DirectClass 50.75MB 0.219u 0:00.500
EPS:C:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-Q8vAEjaT=>C:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-Q8vAEjaT PAM 3087x4113=>3085x4113 3085x4113+0+0 16-bit ColorSeparation DirectClass 50.75MB 0.016u 0:00.093
C:\websites\backend\tasks\cmr\img\44230_460V_07.eps EPT 3087x4113=>3085x4113 3085x4113+0+0 16-bit ColorSeparation DirectClass 50.75MB 0.016u 0:00.093
C:\websites\backend\tasks\cmr\img\44230_460V_07.eps=>C:\websites\backend\tasks\cmr\img-res\44230_460V_07.jpg EPT 3087x4113=>3085x4113 3085x4113+0+0 16-bit ColorSeparation DirectClass 5.521MB 1.766u 0:01.827

I also get a perfectly converted image (or at least as far as I can tell). However, when I use the EXACT same line as a cfexecute in ColdFusion, here is what I get:

Command:
convert -verbose C:\websites\backend\tasks\cmr\img\44230_460V_07.eps -regard-warnings C:\websites\backend\tasks\cmr\img-res\44230_460V_07.jpg || echo bad image
Results:
[ghostscript library] Files/gs/gs9.02/bin/gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r457x457" -g3085x4113 "-sOutputFile=C:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-TXknzLvP-%08d" "-fC:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-6i68Jj4_" "-fC:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-292x9dGz"C:\websites\backend\tasks\cmr\img\44230_460V_07.eps=>C:/Users/ADMINI~1.R2V/AppData/Local/Temp/magick-lWG645uO EPS 3087x4113=>3085x4113 3085x4113+0+0 16-bit ColorSeparation DirectClass 77.15MB 0.734u 0:00.734
C:\websites\backend\tasks\cmr\img\44230_460V_07.eps=> TIFF 3087x4113=>384x512 384x512+0+0 16-bit PseudoClass 256c 226KB 7.047u 0:02.734
C:\websites\backend\tasks\cmr\img\44230_460V_07.eps=>bad image EPT 3087x4113=>3085x4113 3085x4113+0+0 16-bit ColorSeparation DirectClass 77.37MB 8.297u 0:05.781

The main difference I'm seeing here is that with ColdFusion it returns the "bad image". Additionally, no image is actually produced. It seems to be the "echo" that's doing the damage. I think ColdFusion is treating it as some sort of break in the operation, and it never lets the process finish. If I take out the echo and leave in -regards-warnings, it completes fine. However I have no idea if there's any actual warnings now.
pjvedder
Posts: 12
Joined: 2011-06-22T12:39:02-07:00
Authentication code: 8675308

Re: Batch convert and errors logging

Post by pjvedder »

Aside from the obvious problem here with echo, my main problem aside from all of this is that the images that have problems for me (which i mentioned in another topic about paths and image darkening) don't even report a warning that there's something wrong when I run the convert in the actual command line prompt and not ColdFusion. So even if this were to work, it almost seems pointless because if I'm doing a batch conversion, I'll never know if there's a problem without inspecting each image... or at least so it seems.
Post Reply