Re: TIFF compression support list

Bob Friesenhahn <[email protected]> Thu, 28 Sep 2023 10:05:16 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Thu, 28 Sep 2023, frechefuchs via Graphicsmagick-help wrote:

> Hi,
>
> with the newly built binaries, I can see that GM 1.4 seems to indicate
> supported TIFF compression formats:
>
>> $ ./rungm.sh ./utilities/gm convert -list formats
>>    Format L  Mode  Description
>> --------------------------------------------------------------------------------
>> [...]
>>     TIFF P  rw+  Tagged Image File Format (LIBTIFF, Version 4.1.0)
>>             Supported Compressions: None, Fax/Group3, Group4, JBIG, JPEG, LZW, LZMA, RLE, ZIP, ZSTD, WEBP
>
> Yet, the list of compression formats seems to be a static one, since
> this is a no-WEBP build.  The same happens when building with, e.g.,
> --wihout-lzma etc.  Since the list of supported image formats is not a
> static one, but reflects the build's actual capabilities, I wonder if a
> static TIFF compression support list is useful.  It may lead to confusion.

I see that it is based on definitions from libtiff-provided header 
files.  It was my understanding that are tailored based on the libtiff 
build options.  Are you sure that the build is using the 
headers/library that you expect?

> Background is, I wonder if GM can be built without (TIFF) LZW
> compression support.*  Frankly, I don't really grok the zoo of
> mismatching compression format and support library names.

Libtiff can be build without LZW support.  GM will adapt.  But a tiny 
modification to GM code would also disable support for it (see below).

> Fast-forwarding, at <URL:http://www.graphicsmagick.org/formats.html>, I
> found the following note:
>
>> Also known as "TIF". Requires tiff-v3.5.4.tar.gz or later. Note that
>> since the Unisys LZW patent recently expired, libtiff may still
>> require a separate LZW patch in order to support LZW. LZW is included
>> in libtiff by default since v3.7.0.
> So, LZW compression is provided by libtiff itself.  But can it be
> disabled?  Better yet, can LZW compression /write/ support be disabled?

That is funny.  This note must have been written 20 years ago? ;-)

If you edit the coders/tiff.c source file and change code to this, 
then that should work:

#if defined(HasTIFF)
#  if defined(HAVE_TIFFCONF_H)
#    include "tiffconf.h"
#  endif
#  include "tiff.h"
#  include "tiffio.h"
#  undef COMPRESSION_LZW

Note the addition of '#undef COMPRESSION_LZW'.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt