Page 1 of 1
TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-18T06:27:08-07:00
by alexcgt
Compressing TIFF images containing alpha channel using JPG compression will randomly produce corrupt images.
The very same images
without alpha channels will produce the correct output.
Source TIF image:
https://www.dropbox.com/s/3kehra55qw8308q/rgba.tif?dl=0
Screenshot of the compressed source image opened in Photoshop:
Source image has been processed using the following command:
Code: Select all
magick mogrify -compress JPEG -quality 90 rgba.tif
I'm using:
ImageMagick-7.0.8-Q8
Windows 10 Pro
Photoshop 19
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-18T06:46:18-07:00
by snibgo
With IM v7.0.7-28 Q16 on Windows 8.1, your command works for me, making text "ALPHA" in black on a transparent background.
Please paste the text output from "magick -version".
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-18T06:58:16-07:00
by alexcgt
Code: Select all
Version: ImageMagick 7.0.8-0 Q8 x64 2018-06-12 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-18T10:22:35-07:00
by fmw42
It works fine for me also on IM 7.0.8.0 Q16 Mac OSX Sierra. I note that you are using Q8. Perhaps that is the issue. Or perhaps you need to upgrade libtiff?
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-19T00:42:51-07:00
by alexcgt
It didn't work with Q16 either.
Q8, Q16, Dynamic, Static, Win32 -- they all produce corrupt alpha.
Oddly XnView doesn't see the image as corrupted but I don't trust XnView anymore.
And Photoshop shows the image as corrupted.
I was under the impression that IM install has everything that is required. Is libtiff an external library?
Is there any comprehensive upgrade guide?
All I get on the internet is some links to some repositories.
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-19T05:39:48-07:00
by snibgo
Yes, the pre-compiled binaries for ImageMagick on Windows includes libtiff. In your "magick -version", the "Delegates (built-in)" line includes "tiff".
What does "magick -list format" say under TIFF lines? My version 7.0.7-28 says:
Code: Select all
TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.0.9)
TIFF64* TIFF rw- Tagged Image File Format (64-bit) (LIBTIFF, Version 4
.0.9)
Provided yours says 4.0.9 or greater, that should be okay.
Prior to this post, I didn't know that TIFF with JPEG compression could store alpha. It does, successfully for me.
Can you test with ZIP and LZW compression in TIFF? If they work, is one of those a satisfactory workaround for you?
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-20T02:30:38-07:00
by alexcgt
Thanks, snibgo.
At first, I thought it might be the libtiff trouble but it turns out to be something entirely different.
I spent many hours just to find out that the Photoshop indeed doesn't support JPEG-compressed TIFF containing alpha channels.
The problem is that it won't notify you about the invalid image format or that it has some troubles reading the format or something like that!
It will just open the image and will mess up the rightmost vertical quarter of the image (as in the screenshot).
You can actually save TIFF with JPEG compression in Photoshop but only if the image doesn't have an alpha channel.
Which is weird since just about every piece of software I have does process the format correctly.
And that includes Windows Explorer and Slack.
LZW or ZIP compression just won't do it for me since I'm processing high-resolution textures for models and they rarely contain data which is well compressed using non-lossy algorithms.
I've lost my trust in Photoshop.
Thanks for your help, folks!
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-20T02:55:17-07:00
by snibgo
Okay, a Photoshop problem.
Is JP2 an option for you? It compresses photos well, with transparency, and responds to "-quality" in the same way as JPG.
Code: Select all
magick toes_holed.png -quality 40 t.jp2
But JP2 isn't widely supported. I expect current Photoshop supports it, but you'll need to test.
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-20T04:55:08-07:00
by alexcgt
A very interesting suggestion regarding JP2 and Photoshop seems to be opening it correctly.
Unfortunately, I'm constrained by the formats which are supported by Unity3D and it currently doesn't have a support for JP2.
Re: TIFF with alpha produces a corrupt output when JPG compressed.
Posted: 2018-06-20T05:10:17-07:00
by alexcgt
...