GraphicsMagick: ReadTIFFImage(): Require that TIFFTAG_EXTRASAMPL...
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.1293.1685215497.1565.graphicsmagick-commit@lists.sourceforge.net> |
changeset 5c6fd2a5e177 in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=5c6fd2a5e177 summary: ReadTIFFImage(): Require that TIFFTAG_EXTRASAMPLES be used appropriately to indicate the intention of extra channels. diffstat: ChangeLog | 7 +++ VisualMagick/installer/inc/version.isx | 4 +- coders/tiff.c | 68 +++++++++++++++++++--------------- magick/version.h | 4 +- www/Changelog.html | 9 ++++ 5 files changed, 58 insertions(+), 34 deletions(-) diffs (158 lines): diff -r 4e6d0c85f96f -r 5c6fd2a5e177 ChangeLog --- a/ChangeLog Thu May 25 08:38:42 2023 -0500 +++ b/ChangeLog Sat May 27 14:24:44 2023 -0500 @@ -1,3 +1,10 @@ +2023-05-27 Bob Friesenhahn <[email protected]> + + * coders/tiff.c (ReadTIFFImage): Require that TIFFTAG_EXTRASAMPLES + be used appropriately to indicate the intention of extra channels. + Otherwise extra samples beyond what is required by the photometric + will be ignored. + 2023-05-25 Bob Friesenhahn <[email protected]> * coders/tiff.c (ReadTIFFImage): Stop promoting RGB image to diff -r 4e6d0c85f96f -r 5c6fd2a5e177 VisualMagick/installer/inc/version.isx --- a/VisualMagick/installer/inc/version.isx Thu May 25 08:38:42 2023 -0500 +++ b/VisualMagick/installer/inc/version.isx Sat May 27 14:24:44 2023 -0500 @@ -10,5 +10,5 @@ #define public MagickPackageName "GraphicsMagick" #define public MagickPackageVersion "1.4" -#define public MagickPackageVersionAddendum ".020230525" -#define public MagickPackageReleaseDate "snapshot-20230525" +#define public MagickPackageVersionAddendum ".020230527" +#define public MagickPackageReleaseDate "snapshot-20230527" diff -r 4e6d0c85f96f -r 5c6fd2a5e177 coders/tiff.c --- a/coders/tiff.c Thu May 25 08:38:42 2023 -0500 +++ b/coders/tiff.c Sat May 27 14:24:44 2023 -0500 @@ -736,6 +736,27 @@ return result; } +static const char *ExtraSampleToString(const unsigned int sample_info) +{ + const char + *result = "Unknown"; + + switch (sample_info) + { + case EXTRASAMPLE_UNSPECIFIED: + result="Unspecified data"; + break; + case EXTRASAMPLE_ASSOCALPHA: + result="Associated alpha data (with pre-multiplied color)"; + break; + case EXTRASAMPLE_UNASSALPHA: + result="Unassociated alpha data"; + break; + } + + return result; +} + /* Locate and store Photoshop or IPTC profiles. @@ -2225,51 +2246,38 @@ if (extra_samples != 0) { - /* FIXME: Is it ok to make this gross assumption? */ - alpha_type=AssociatedAlpha; - image->matte=True; - if (sample_info[0] == EXTRASAMPLE_UNSPECIFIED) - alpha_type=UnspecifiedAlpha; + { + alpha_type=UnspecifiedAlpha; + } else if (sample_info[0] == EXTRASAMPLE_UNASSALPHA) - alpha_type=UnassociatedAlpha; + { + alpha_type=UnassociatedAlpha; + image->matte=True; + } else if (sample_info[0] == EXTRASAMPLE_ASSOCALPHA) - alpha_type=AssociatedAlpha; + { + alpha_type=AssociatedAlpha; + image->matte=True; + } } if (image->logging) for (sample_index=0 ; sample_index < extra_samples; sample_index++) { (void) LogMagickEvent(CoderEvent,GetMagickModule(), - "Extra sample %u contains %s alpha",sample_index+1, - ((sample_info[sample_index] == EXTRASAMPLE_ASSOCALPHA) ? "ASSOCIATED" : - (sample_info[sample_index] == EXTRASAMPLE_UNASSALPHA) ? "UNASSOCIATED" : - "UNSPECIFIED")); + "Extra sample %u contains %s",sample_index+1, + ExtraSampleToString(sample_info[sample_index])); } } /* - Handle RGBA images which are improperly marked. + Report RGBA images which may be improperly marked. */ - if (extra_samples == 0) + if ((image->logging) && (extra_samples == 0)) if ((photometric == PHOTOMETRIC_RGB) && (samples_per_pixel == 4)) { -#if 0 - - /* - FIXME: Temporarily (?) disabled until a solution is found - which does not cause issues. - */ (void) LogMagickEvent(CoderEvent,GetMagickModule(), - "Promoting RGB image to associated alpha due to" - " samples-per-pixel=%u", samples_per_pixel); - extra_samples=1; - alpha_type=AssociatedAlpha; - image->matte=MagickTrue; -#else - (void) LogMagickEvent(CoderEvent,GetMagickModule(), - "Photometric is RGB but %u samples/pixel provided!", - samples_per_pixel); - ThrowTIFFReaderException(CorruptImageError,ImproperImageHeader,image); -#endif + "Photometric is RGB but %u samples/pixel and %u extra_samples provided!", + samples_per_pixel, extra_samples); } /* diff -r 4e6d0c85f96f -r 5c6fd2a5e177 magick/version.h --- a/magick/version.h Thu May 25 08:38:42 2023 -0500 +++ b/magick/version.h Sat May 27 14:24:44 2023 -0500 @@ -38,8 +38,8 @@ #define MagickLibVersion 0x272402 #define MagickLibVersionText "1.4" #define MagickLibVersionNumber 27,24,2 -#define MagickChangeDate "20230525" -#define MagickReleaseDate "snapshot-20230525" +#define MagickChangeDate "20230527" +#define MagickReleaseDate "snapshot-20230527" /* The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines diff -r 4e6d0c85f96f -r 5c6fd2a5e177 www/Changelog.html --- a/www/Changelog.html Thu May 25 08:38:42 2023 -0500 +++ b/www/Changelog.html Sat May 27 14:24:44 2023 -0500 @@ -37,6 +37,15 @@ </div> <div class="document"> +<p>2023-05-27 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> +<blockquote> +<ul class="simple"> +<li><p>coders/tiff.c (ReadTIFFImage): Require that TIFFTAG_EXTRASAMPLES +be used appropriately to indicate the intention of extra channels. +Otherwise extra samples beyond what is required by the photometric +will be ignored.</p></li> +</ul> +</blockquote> <p>2023-05-25 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> <blockquote> <ul class="simple">