Page 1 of 1
Help with bad JPEG images converted from TIF
Posted: 2014-03-05T08:03:19-07:00
by Exilas
Hi all,
I'm at a loss investigating an issue we had with JPEG images obtained from TIFF originals. This is a sample JPEG showing the issue.
Of course, the man has colors in the original TIFF, which is very large (about 550MB); however, size doesn't seem to be a factor, since other large TIFFs get converted correctly. The shaded gray background is correct, only the "overimposed" man is wrong.
I tried to compare a good and a bad TIFF using some analyzing tools, but I saw no evident difference that could explain this behaviour.
To complicate the issue further, I'm using a third-part SW that embeds some unknown version of IM for image processing; I can only modify the XML profile that's fed to IM, which is the following:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<IMW_MP_PROPERTIES>
<OutputFormat>JPEG</OutputFormat>
<Pages>0</Pages>
<PROP name="Width" type="unsigned long" token="doc_token_width_tn">100</PROP>
<PROP name="Height" type="unsigned long" token="doc_token_height_tn">100</PROP>
<PROP name="enlarge" type="string" token="doc_token_enlarge">false</PROP>
<Options>-limit memory doc_token_limit_memory -limit map doc_token_limit_map -limit area doc_token_limit_area -flatten -quality 80 -strip -filter Lanczos -profile "doc_token_cmyk_profile" -profile "doc_token_rgb_profile" -profile "doc_token_colorProfile" -colorspace doc_token_colorSpace</Options>
</IMW_MP_PROPERTIES>
Could you please hint about some possible cause or suggest a line of investigation?
Thanks
Re: Help with bad JPEG images converted from TIF
Posted: 2014-03-05T08:28:03-07:00
by snibgo
I suspect it is a clipping path, often used to block-out backgrounds. See
http://www.imagemagick.org/script/comma ... s.php#clip and following options.
Failing that, it's a bit large to put the tiff file somewhere like dropbox.com and paste the URL here, so:
and paste the output here, between [ code ] and [ /code ].
Re: Help with bad JPEG images converted from TIF
Posted: 2014-03-05T08:59:12-07:00
by Exilas
Snibgo,
thanks for your reply.
I see no clip option in the profile XML, so I guess the reason may be different.
Please find below the identify -verbose ouptut for both a good and a bad TIFF. I can't spot any real difference in the two files, but I'm a novice at this.
Any further help is really appreciated.
Thanks
BAD
Code: Select all
Image: d:\Downloads\11_077.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 7320x5484+0+0
Resolution: 300x300
Print size: 24.4x18.28
Units: PixelsPerInch
Type: ColorSeparationAlpha
Base type: ColorSeparation
Endianess: MSB
Colorspace: CMYK
Depth: 8-bit
Channel depth:
cyan: 8-bit
magenta: 8-bit
yellow: 8-bit
black: 8-bit
alpha: 8-bit
Channel statistics:
Cyan:
min: 0 (0)
max: 255 (1)
mean: 137.161 (0.537885)
standard deviation: 49.3868 (0.193674)
kurtosis: 0.265992
skewness: -0.137577
Magenta:
min: 0 (0)
max: 255 (1)
mean: 115.633 (0.453463)
standard deviation: 51.4055 (0.20159)
kurtosis: 0.211594
skewness: 0.39526
Yellow:
min: 0 (0)
max: 243 (0.952941)
mean: 95.3686 (0.373994)
standard deviation: 35.662 (0.139851)
kurtosis: -0.0948723
skewness: 0.0534431
Black:
min: 0 (0)
max: 239 (0.937255)
mean: 83.3326 (0.326794)
standard deviation: 52.4248 (0.205587)
kurtosis: 0.229723
skewness: 0.571227
Alpha:
min: 0 (0)
max: 255 (1)
mean: 182.814 (0.716917)
standard deviation: 114.658 (0.44964)
kurtosis: -1.06912
skewness: 0.963103
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 100.736 (0.395044)
standard deviation: 66.7056 (0.261591)
kurtosis: 0.322236
skewness: 0.465718
Total ink density: 354.51%
Alpha: cmyka(232,226,151,211,0) #E8E297D300
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: cmyka(255,255,255,0,1)
Border color: cmyka(223,223,223,0,1)
Matte color: cmyka(189,189,189,0,1)
Transparent color: cmyka(0,0,0,0,0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 7320x5484+0+0
Dispose: Undefined
Iterations: 0
Compression: None
Orientation: TopLeft
Properties:
date:create: 2014-03-04T18:16:09+01:00
date:modify: 2014-03-04T18:16:18+01:00
exif:ApertureValue: 8
exif:DateTimeDigitized: 2013:06:14 19:45:43
exif:DateTimeOriginal: 2013:06:14 19:45:43
exif:ExposureTime: 0.00200001
exif:FNumber: 16
exif:FocalLength: 80
exif:ISOSpeedRatings: 50
exif:LightSource: 255
exif:PixelXDimension: 7320
exif:PixelYDimension: 5484
exif:ShutterSpeedValue: 8.96578
icc:copyright: PrintOpen 5.2.0 - (c) Copyright 2000-2006 Heidelberger Druckmaschinen AG. All Rights Reserved.
icc:description: ISO Coated v2 (ECI)
icc:manufacturer: ISO Coated v2 (ECI)
icc:model: ISO Coated v2 (ECI)
rdf:Bag:
signature: 2f9bca4b81ed252dcdf11b9771feb86dc5df0b0c765946e72135922b8527a2b7
tiff:alpha: unassociated
tiff:endian: msb
tiff:make: Phase One
tiff:model: IQ140
tiff:photometric: separated
tiff:rows-per-strip: 1
tiff:software: Adobe Photoshop CS5 Macintosh
tiff:timestamp: 2013:07:16 15:54:30
Profiles:
Profile-8bim: 25746 bytes
Profile-icc: 1829077 bytes
Profile-tiff:37724: 322482064 bytes
Profile-xmp: 17526 bytes
Artifacts:
filename: d:\Downloads\11_077.tif
verbose: true
Tainted: False
Filesize: 525.1MB
Number pixels: 40.14M
Pixels per second: 1.115MB
User time: 3.156u
Elapsed time: 0:37.014
Version: ImageMagick 6.8.8-7 Q16 x86 2014-02-13 http://www.imagemagick.org
GOOD
Code: Select all
Image: d:\Downloads\18_091.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 5134x7081+0+0
Resolution: 300x300
Print size: 17.1133x23.6033
Units: PixelsPerInch
Type: ColorSeparationAlpha
Base type: ColorSeparation
Endianess: MSB
Colorspace: CMYK
Depth: 8-bit
Channel depth:
cyan: 8-bit
magenta: 8-bit
yellow: 8-bit
black: 8-bit
alpha: 8-bit
Channel statistics:
Cyan:
min: 0 (0)
max: 253 (0.992157)
mean: 125.009 (0.49023)
standard deviation: 47.7624 (0.187304)
kurtosis: 1.24037
skewness: -0.35695
Magenta:
min: 0 (0)
max: 255 (1)
mean: 126.405 (0.495707)
standard deviation: 52.4278 (0.205599)
kurtosis: 0.619188
skewness: 1.36218
Yellow:
min: 0 (0)
max: 232 (0.909804)
mean: 101.957 (0.39983)
standard deviation: 20.5659 (0.0806505)
kurtosis: 1.60634
skewness: 1.01318
Black:
min: 0 (0)
max: 232 (0.909804)
mean: 82.2312 (0.322475)
standard deviation: 43.8796 (0.172077)
kurtosis: 1.53956
skewness: 1.28264
Alpha:
min: 0 (0)
max: 255 (1)
mean: 74.6512 (0.29275)
standard deviation: 115.778 (0.45403)
kurtosis: -1.16644
skewness: -0.910974
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 123.19 (0.483098)
standard deviation: 64.4714 (0.252829)
kurtosis: 1.10045
skewness: 0.778629
Total ink density: 334.902%
Alpha: cmyka(124,98,95,65,0) #7C625F4100
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: cmyka(255,255,255,0,1)
Border color: cmyka(223,223,223,0,1)
Matte color: cmyka(189,189,189,0,1)
Transparent color: cmyka(0,0,0,0,0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 5134x7081+0+0
Dispose: Undefined
Iterations: 0
Compression: None
Orientation: TopLeft
Properties:
date:create: 2014-03-05T14:57:19+01:00
date:modify: 2014-03-05T14:57:19+01:00
exif:ApertureValue: 8
exif:DateTimeDigitized: 2013:06:14 19:09:57
exif:DateTimeOriginal: 2013:06:14 19:09:57
exif:ExposureTime: 0.00200001
exif:FNumber: 16
exif:FocalLength: 80
exif:ISOSpeedRatings: 50
exif:LightSource: 255
exif:PixelXDimension: 5134
exif:PixelYDimension: 7081
exif:ShutterSpeedValue: 8.96578
icc:copyright: PrintOpen 5.2.0 - (c) Copyright 2000-2006 Heidelberger Druckmaschinen AG. All Rights Reserved.
icc:description: ISO Coated v2 (ECI)
icc:manufacturer: ISO Coated v2 (ECI)
icc:model: ISO Coated v2 (ECI)
rdf:Bag:
signature: f1a24d9ccbb2496d4d86c0db636c1c15f5353c90ce7e0b8101e67f57fc7e041e
tiff:alpha: unassociated
tiff:endian: lsb
tiff:make: Phase One
tiff:model: IQ140
tiff:photometric: separated
tiff:rows-per-strip: 1
tiff:software: Adobe Photoshop CS5 Macintosh
tiff:timestamp: 2013:07:26 14:22:58
Profiles:
Profile-8bim: 5614 bytes
Profile-icc: 1829077 bytes
Profile-tiff:37724: 283547716 bytes
Profile-xmp: 19766 bytes
Artifacts:
filename: d:\Downloads\18_091.tif
verbose: true
Tainted: False
Filesize: 467.2MB
Number pixels: 36.35M
Pixels per second: 2.104MB
User time: 2.672u
Elapsed time: 0:18.281
Version: ImageMagick 6.8.8-7 Q16 x86 2014-02-13 http://www.imagemagick.org
Re: Help with bad JPEG images converted from TIF
Posted: 2014-03-05T09:29:55-07:00
by snibgo
You have unassociated alpha. Try "-alpha off".
Re: Help with bad JPEG images converted from TIF
Posted: 2014-03-06T08:15:40-07:00
by Exilas
Unfortunately -alpha off didn't any good.
To a profane (me) eye, it'd seem like the image has two layers, and for some reason one is "cropped off" during the jpeg creation. However, I see the -flatten option set, so I guess that option should address such kind of layers issue.
Any other help is greatly appreciated.
Re: Help with bad JPEG images converted from TIF
Posted: 2014-03-06T08:49:20-07:00
by snibgo
Multiple layers are possible; Photoshop can "hide" layers that IM can't see. The bad file has "Profile-tiff:37724: 322482064 bytes", which is an awful lot of bytes, half the file.
Have you tried, from the command line:
Code: Select all
convert bad.tiff -alpha off -strip x.png
You might also try:
Code: Select all
exiftool -s2 -all -b -X -fXMP:XMP bad.tiff>badtiff.txt
... and post the results here.
Re: Help with bad JPEG images converted from TIF
Posted: 2014-03-06T11:13:59-07:00
by Exilas
I managed to track down the exact command that is issued by the system:
Code: Select all
convert.exe 11_077.tif -colorspace RGB -density 96 -limit memory 2048 -limit map 4096 -limit area 8192 -background white -flatten -quality 80 -strip -filter Lanczos -profile "sRGB Color Space Profile.icm" -colorspace RGB -resize 300x300 11_077.jpg
I did a lot of trial-and-error unwitting attempts, and I discovered that by removing both the
-flatten and
-resize 300x300 options the output jpeg looks fine.
Does that make any sense to you? Do you see a way to resize the image without mangling it? Is the double
-colorspace RGB option really needed? Is the sRGB profile coherent with the RGB colorspace? What difference in the original TIFFs makes that command good for one and bad for the other?
I feel utterly out of my depth...
Thanks a lot!
Re: Help with bad JPEG images converted from TIF
Posted: 2014-03-06T11:59:04-07:00
by snibgo
What version of IM? ("convert -version".)
For recent versions of IM, "-colorspace RGB" would be bad news, and give incorrect results. For old versions, it may be needed. In the bad old days, IM had sRGB and RGB the wrong way round. I forget when that was corrected.
"-strip" is bad, and you should remove it. Both files contain CMYK colour profiles, and the correct way to convert them to sRGB is with another "-profile", which converts pixels from the old profile to the new one. But "-strip" removes the old profile, it just wipes it out, so IM can't then convert the pixels from the old profile to the new one. (As the command stands, "-profile" does nothing, and the conversion from CMYK to RGB is done by one of the "-colorspace" operations.)
"-background white -flatten" puts white behind the image and removes transparency, making each pixel the appropriate mix of its previous colour and white. If you don't "-flatten", then converting to jpeg should simply remove transparency, without changing the colour. Using "-alpha off" should also do this. But putting "-alpha off" after "-flatten" will do nothing, as by then there is no alpha to turn off.
"-resize 300x300" should make no difference to transparency, or anything else really. Apart from the size, of course.
See
http://www.imagemagick.org/script/comma ... ptions.php for the detail of each operation.
Re: Help with bad JPEG images converted from TIF
Posted: 2014-03-07T04:51:37-07:00
by Exilas
Snibgo,
once again thanks for your help. In the end, I managed to solve the issue; due to some limitation I have in changing the parameters fed to IM (some are sort of "builtin"), this is the issued command now:
Code: Select all
convert.exe 11_077.tif -colorspace RGB -density 96 -limit memory 2048 -limit map 4096 -limit area 8192 -background white -alpha off -quality 80 -strip -filter Lanczos -profile "sRGB Color Space Profile.icm" -colorspace RGB -resize 300x300 11_077.jpg
that is, I replaced -flatten with -alpha off, and this seems to do the trick.
It still escapes me which is really the difference between the good and bad original TIFFs, but I guess I can live nonetheless
Really, I wouldn't have come out of this mess without your kind help. Thanks and kudos.
Regards