Skip to content

Commit

Permalink
Fixed writing the iptc information when it is not stored as long.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Jul 18, 2021
1 parent d881b80 commit f4feb3e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions coders/tiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,9 @@ static void TIFFSetProfiles(TIFF *tiff,Image *image)
#endif
if (LocaleCompare(name,"iptc") == 0)
{
const TIFFField
*field;

size_t
length;

Expand All @@ -2936,11 +2939,20 @@ static void TIFFSetProfiles(TIFF *tiff,Image *image)
length=GetStringInfoLength(profile)+4-(GetStringInfoLength(profile) &
0x03);
SetStringInfoLength(iptc_profile,length);
if (TIFFIsByteSwapped(tiff))
TIFFSwabArrayOfLong((uint32 *) GetStringInfoDatum(iptc_profile),
(unsigned long) (length/4));
(void) TIFFSetField(tiff,TIFFTAG_RICHTIFFIPTC,(uint32)
GetStringInfoLength(iptc_profile)/4,GetStringInfoDatum(iptc_profile));
field=TIFFFieldWithTag(tiff,TIFFTAG_RICHTIFFIPTC);
if (TIFFFieldDataType(field) == TIFF_LONG)
{
if (TIFFIsByteSwapped(tiff))
TIFFSwabArrayOfLong((uint32 *) GetStringInfoDatum(iptc_profile),
(unsigned long) (length/4));
(void) TIFFSetField(tiff,TIFFTAG_RICHTIFFIPTC,(uint32)
GetStringInfoLength(iptc_profile)/4,GetStringInfoDatum(
iptc_profile));
}
else
(void) TIFFSetField(tiff,TIFFTAG_RICHTIFFIPTC,(uint32)
GetStringInfoLength(iptc_profile),GetStringInfoDatum(
iptc_profile));
iptc_profile=DestroyStringInfo(iptc_profile);
}
#if defined(TIFFTAG_PHOTOSHOP)
Expand Down

0 comments on commit f4feb3e

Please sign in to comment.