GraphicsMagick: ReadTIFFImage(): Restore reading the alpha chann...
GraphicsMagick Commits <[email protected]> Wed, 16 Aug 2023 17:52:10 -0500
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.9566.1692226343.1761.graphicsmagick-commit@lists.sourceforge.net> |
changeset 15a0fc19fa0c in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=15a0fc19fa0c summary: ReadTIFFImage(): Restore reading the alpha channel for TIFF files with unspecified alpha diffstat: ChangeLog | 9 ++++++ VisualMagick/installer/inc/version.isx | 4 +- coders/tiff.c | 45 +++++++++++++++++++++++++++++---- magick/utility.c | 4 +++ magick/version.h | 4 +- www/Changelog.html | 11 ++++++++ 6 files changed, 67 insertions(+), 10 deletions(-) diffs (159 lines): diff -r 9c19dbaa7b31 -r 15a0fc19fa0c ChangeLog --- a/ChangeLog Tue Aug 15 18:15:35 2023 -0500 +++ b/ChangeLog Wed Aug 16 17:52:06 2023 -0500 @@ -1,3 +1,12 @@ +2023-08-16 Bob Friesenhahn <[email protected]> + + * coders/tiff.c (ReadTIFFImage): For common formats with the + required number of channels, but one is an 'unspecified' channel, + promote unspecified alpha to unassociated alpha so that the alpha + channel is not ignored. Addresses the remainder of SourceForge + issue #718 "Set reasonable defaults when writing TIFF with + transparency". + 2023-08-15 Bob Friesenhahn <[email protected]> * Makefile.am (CHANGELOGS): Changelogs ChangeLog.2021 and diff -r 9c19dbaa7b31 -r 15a0fc19fa0c VisualMagick/installer/inc/version.isx --- a/VisualMagick/installer/inc/version.isx Tue Aug 15 18:15:35 2023 -0500 +++ b/VisualMagick/installer/inc/version.isx Wed Aug 16 17:52:06 2023 -0500 @@ -10,5 +10,5 @@ #define public MagickPackageName "GraphicsMagick" #define public MagickPackageVersion "1.4" -#define public MagickPackageVersionAddendum ".020230815" -#define public MagickPackageReleaseDate "snapshot-20230815" +#define public MagickPackageVersionAddendum ".020230816" +#define public MagickPackageReleaseDate "snapshot-20230816" diff -r 9c19dbaa7b31 -r 15a0fc19fa0c coders/tiff.c --- a/coders/tiff.c Tue Aug 15 18:15:35 2023 -0500 +++ b/coders/tiff.c Wed Aug 16 17:52:06 2023 -0500 @@ -2239,6 +2239,7 @@ /* Obtain information about any extra samples. + FIXME samples_per_pixel = 4 and 1 extra sample which is 'unspecified' */ extra_samples=0; if (TIFFGetField(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples, @@ -2256,12 +2257,10 @@ else if (sample_info[0] == EXTRASAMPLE_UNASSALPHA) { alpha_type=UnassociatedAlpha; - image->matte=True; } else if (sample_info[0] == EXTRASAMPLE_ASSOCALPHA) { alpha_type=AssociatedAlpha; - image->matte=True; } } if (image->logging) @@ -2276,13 +2275,30 @@ Report RGBA images which may be improperly marked. */ if ((image->logging) && (extra_samples == 0)) - if ((photometric == PHOTOMETRIC_RGB) && (samples_per_pixel == 4)) + if (((PHOTOMETRIC_RGB == photometric) && (samples_per_pixel == 4)) || + (((PHOTOMETRIC_MINISWHITE == photometric) || (PHOTOMETRIC_MINISBLACK == photometric)) && (samples_per_pixel == 2))) { (void) LogMagickEvent(CoderEvent,GetMagickModule(), - "Photometric is RGB but %u samples/pixel and %u extra_samples provided!", - samples_per_pixel, extra_samples); + "Photometric is %s but %u samples/pixel and %u extra_samples provided!", + PhotometricTagToString(photometric),samples_per_pixel, extra_samples); } - + /* + Deal with files which are marked as unspecified alpha, but + they should be unassociated alpha. + */ + if (((extra_samples == 1) && (sample_info[0] == EXTRASAMPLE_UNSPECIFIED)) && + ( + ((samples_per_pixel == 2) && ((PHOTOMETRIC_MINISWHITE == photometric) || (PHOTOMETRIC_MINISBLACK == photometric))) || + ((samples_per_pixel == 4) && (PHOTOMETRIC_RGB == photometric)) || + ((samples_per_pixel == 5) && (PHOTOMETRIC_SEPARATED == photometric)) + ) + ) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "Promoting UnspecifiedAlpha to UnassociatedAlpha"); + alpha_type=UnassociatedAlpha; + image->matte=True; + } /* Allow the user to over-ride the alpha channel type. */ @@ -2300,6 +2316,23 @@ } /* + Does alpha type deserve a matte channel? + */ + switch(alpha_type) + { + case UnspecifiedAlpha: + break; + case UnassociatedAlpha: + image->matte=True; + break; + case AssociatedAlpha: + image->matte=True; + break; + default: + break; + } + + /* Describe how the alpha channel will be treated. */ if (image->matte) diff -r 9c19dbaa7b31 -r 15a0fc19fa0c magick/utility.c --- a/magick/utility.c Tue Aug 15 18:15:35 2023 -0500 +++ b/magick/utility.c Wed Aug 16 17:52:06 2023 -0500 @@ -1951,6 +1951,10 @@ *value=0.0; errno=ERANGE; } + /* + Warning: Visual Studio 2008 64-bit returns errno 34 "Result too + large", even though a correct value is returned! + */ else if (errno == 0) { n++; diff -r 9c19dbaa7b31 -r 15a0fc19fa0c magick/version.h --- a/magick/version.h Tue Aug 15 18:15:35 2023 -0500 +++ b/magick/version.h Wed Aug 16 17:52:06 2023 -0500 @@ -38,8 +38,8 @@ #define MagickLibVersion 0x272403 #define MagickLibVersionText "1.4" #define MagickLibVersionNumber 27,24,3 -#define MagickChangeDate "20230815" -#define MagickReleaseDate "snapshot-20230815" +#define MagickChangeDate "20230816" +#define MagickReleaseDate "snapshot-20230816" /* The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines diff -r 9c19dbaa7b31 -r 15a0fc19fa0c www/Changelog.html --- a/www/Changelog.html Tue Aug 15 18:15:35 2023 -0500 +++ b/www/Changelog.html Wed Aug 16 17:52:06 2023 -0500 @@ -37,6 +37,17 @@ </div> <div class="document"> +<p>2023-08-16 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): For common formats with the +required number of channels, but one is an 'unspecified' channel, +promote unspecified alpha to unassociated alpha so that the alpha +channel is not ignored. Addresses the remainder of SourceForge +issue #718 "Set reasonable defaults when writing TIFF with +transparency".</p></li> +</ul> +</blockquote> <p>2023-08-15 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">