Page 1 of 1

Image correctly resized but exit code 1

Posted: 2010-12-15T02:56:42-07:00
by notanumber
Hello all,

I am trying to resize tiffs as jpeg with this command:
#convert "mytiff.tif" -resize "200x150" jpeg:"mytiff.tif.thumbnail"
For some tiffs, the picture is correctly resized, but exit code is 1 (instead of 0)

# echo $?
1

output with -verbose:
mytiff.tif TIFF 3543x4724=>8x10 DirectClass 83.9mb 1.440u 0:05
mytiff.tif=>mytiff.tif.thumbnail TIFF 3543x4724=>8x150 DirectClass 344


My IM version: ImageMagick-6.2.4 (imposed by my provider).

Without -resize option:
#convert "mytiff.tif" jpeg:"mytiff.tif.thumbnail"
the exit code is 0

#convert "mytiff.tif" -debug All -resize "200x150" jpeg:"mytiff.tif.thumbnail"
-> nothing is wrong, except:
Exception convert[pid]: tiff.c/TIFFWarnings/280/Exception mytiff.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory'
Exception convert[pid]: tiff.c/TIFFWarnings/280/Exception mytiff.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory'

but... as i said, some other tiffs are correctly resized AND return 0 as exit code.
This exception message also appear for these 'correct' resized pictures.

Have you an idea about the cause ?
I really need to use this exit code. Here, this one seems to be only a warning. Have you a solution to differentiate 'fatal errors' and 'warnings' with my IM version ?


Thanks

Re: Image correctly resized but exit code 1

Posted: 2010-12-17T03:55:48-07:00
by notanumber
Maybe you need more information to answer my question ;)

I have started identify on my erroneous picture. Here is an extract:

documents/new folder 2/7-THIAGO01.tif TIFF 3543x4724 DirectClass 83.9mb 1.060u 0:13
Image: documents/new folder 2/7-THIAGO01.tif
Format: TIFF (Tagged Image File Format)
Geometry: 3543x4724
Class: DirectClass
Type: TrueColor
Endianess: MSB
Colorspace: RGB
Channel depth:
Red: 8-bits
Green: 8-bits
Blue: 8-bits
Channel statistics:
Red:
Min: 0 (0)
Max: 255 (1)
Mean: 60.9369 (0.238968)
Standard deviation: 64.0459 (0.25116)
Green:
Min: 0 (0)
Max: 255 (1)
Mean: 67.7967 (0.265869)
Standard deviation: 67.9198 (0.266352)
Blue:
Min: 0 (0)
Max: 255 (1)
Mean: 82.5727 (0.323814)
Standard deviation: 73.4435 (0.288014)
Colors: 292194
Rendering-intent: Undefined
Resolution: 300x300
Units: PixelsPerInch
Filesize: 83.9mb
Interlace: None
Background Color: white
Border Color: #DFDFDF
Matte Color: grey74
Dispose: Undefined
Iterations: 0
Compression: LZW
Orientation: TopLeft
Make: Canon
Model: Canon EOS 5D Mark II
Signature: b96168739f3d17b19f9cccf361889f60947e5e1d8f910161dc5fe7e85c61bab9
Software: Adobe Photoshop CS4 Macintosh
Timestamp: 2010:05:06 18:27:10
Profile-icc: 560 bytes

Do not hesitate if something is missing for a beginning of answer.

Thank you :)

Re: Image correctly resized but exit code 1

Posted: 2010-12-17T05:23:22-07:00
by notanumber
And now, the ultimate debug message :

documents/new folder 2/7-THIAGO01.tif TIFF 3543x4724=>113x150 DirectClass 83.9mb 2.690u 0:05
documents/new folder 2/7-THIAGO01.tif=>7-THIAGO01.tif.thumbnail TIFF 3543x4724=>113x150 DirectClass 35kb
convert: documents/new folder 2/7-THIAGO01.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory'.

I have only added the ' 2>&1 ' at the end of the command line...

Is it a way to ask IM to ignore this warning, in order to return 0 as exit code, instead of 1 ? (note that the image is correctly resized)

A workaround could be (in my PHP code):
convert "mytiff.tif" -resize "200x150" jpeg:"mytiff.tif.thumbnail" 2>&1
if exit code is 1:
--if output contains $originalFile=>$thumbnailFile and DirectClass and a size
----consider that everything is ok

The remaining problem: how to do it with :
convert "mytiff.tif" -resize "200x150" jpeg:"-" 2>&1
i.e. with picture direct output ?

Re: Image correctly resized but exit code 1

Posted: 2013-07-31T23:58:28-07:00
by alokob
Same issue observed by me , is there any solution for this. I am getting PNG's from tiff but exit code 1.

Re: Image correctly resized but exit code 1

Posted: 2013-08-01T01:06:16-07:00
by notanumber
I have not found any ideal solution, I don't take care of the error code in some cases.

Re: Image correctly resized but exit code 1

Posted: 2013-08-01T09:22:55-07:00
by fmw42
I suspect you are getting an exit error because of the warning about the unknown field. That is just a warning and will not affect the image result. You may be able to get rid of the warning by adding -quiet to your command.

see
http://www.imagemagick.org/Usage/basics/#controls