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 e80cbdf commit 9f44f1e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions coders/tiff.c
Expand Up @@ -3177,6 +3177,9 @@ static void TIFFSetProfiles(TIFF *tiff,Image *image)
#endif
if (LocaleCompare(name,"iptc") == 0)
{
const TIFFField
*field;

size_t
length;

Expand All @@ -3187,11 +3190,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 9f44f1e

Please sign in to comment.