[Pkg-gmagick-im-team] Bug#1128804: setting the PNG background with ImageMagick garbles iTXt tags; pngcheck+pnginfo don't issue an error or a warning

Peter Müller PeterMueller at ro.ru
Mon Feb 23 01:04:36 GMT 2026


Package: imagemagick-7.q16
Version: 8:7.1.1.43+dfsg1-1+deb13u5
Control: affects -1 pngtools pngcheck

Magick's attempt to set the background in a PNG file with title and author chunks mutilates these chunks. On the resulting file, pngcheck+pnginfo together print inconclusive results.

First, grab https://www.debian.org/logos/openlogo-nd-75.png and set its author and title:

$ pngcrush -brute -iTXt b Author de Autor "Max Mustermann" -iTXt b Title de Titel "Debian Logo" openlogo-nd-75.png openlogo-nd-75.with_author_title.png
   Recompressing IDAT chunks in openlogo-nd-75.png to openlogo-nd-75.with_author_title.png
    Total length of data found in critical chunks            =      1044
    Best pngcrush method        =   4 (ws 13 fm 0 zl 9 zs 1) =      1044
CPU time decode 0.054039, encode 0.261401, other 0.032897, total 0.404500 sec
$ pnginfo openlogo-nd-75.with_author_title.png
openlogo-nd-75.with_author_title.png...
   Image Width: 75 Image Length: 92
   Bitdepth (Bits/Sample): 8
   Channels (Samples/Pixel): 1
   Pixel depth (Pixel Depth): 8
   Colour Type (Photometric Interpretation): PALETTED COLOUR (0 colours, 0 transparent)
   Image filter: Single row per byte filter
   Interlacing: No interlacing
   Compression Scheme: Deflate method 8, 32k window
   Resolution: 2834, 2834 (pixels per meter)
   FillOrder: msb-to-lsb
   Byte Order: Network (Big Endian)
   Number of text strings: 2
     Author (iTXt uncompressed): Max Mustermann
     Title (iTXt uncompressed): Debian Logo
$ pngcheck -v openlogo-nd-75.with_author_title.png
zlib warning:  different version (expected 1.2.13, using 1.3.1)
  
File: openlogo-nd-75.with_author_title.png (1181 bytes)
   chunk IHDR at offset 0x0000c, length 13
     75 x 92 image, 8-bit palette, non-interlaced
   chunk PLTE at offset 0x00025, length 51: 17 palette entries
   chunk bKGD at offset 0x00064, length 1
     index = 0
   chunk pHYs at offset 0x00071, length 9: 2834x2834 pixels/meter (72 dpi)
   chunk tIME at offset 0x00086, length 7:  2 Jan 2002 22:07:57 UTC
   chunk iTXt at offset 0x00099, length 32, keyword: Author
     uncompressed, language tag = de
     21 bytes of translated keyword and UTF-8 text
   chunk iTXt at offset 0x000c5, length 28, keyword: Title
     uncompressed, language tag = de
     18 bytes of translated keyword and UTF-8 text
   chunk IDAT at offset 0x000ed, length 924
     zlib: deflated, 8K window, maximum compression
   chunk IEND at offset 0x00495, length 0
No errors detected in openlogo-nd-75.with_author_title.png (9 chunks, 82.9% compression).
$ exiftool -a -G openlogo-nd-75.with_author_title.png|egrep "^\[(PNG|ExifTool)\]"
[ExifTool]      ExifTool Version Number         : 13.25
[PNG]           Image Width                     : 75
[PNG]           Image Height                    : 92
[PNG]           Bit Depth                       : 8
[PNG]           Color Type                      : Palette
[PNG]           Compression                     : Deflate/Inflate
[PNG]           Filter                          : Adaptive
[PNG]           Interlace                       : Noninterlaced
[PNG]           Palette                         : (Binary data 51 bytes, use -b option to extract)
[PNG]           Background Color                : 0
[PNG]           Pixels Per Unit X               : 2834
[PNG]           Pixels Per Unit Y               : 2834
[PNG]           Pixel Units                     : meters
[PNG]           Modify Date                     : 2002:01:02 22:07:57
[PNG]           Author (de)                     : Max Mustermann
[PNG]           Title (de)                      : Debian Logo

All this looks good so far (up to https://bugs.debian.org/1115281).

Second, set the background color and check the result:

$ magick openlogo-nd-75.with_author_title.png -background white openlogo-nd-75.with_author_title.with_background.png
$ pnginfo openlogo-nd-75.with_author_title.with_background.png
openlogo-nd-75.with_author_title.with_background.png...
   Image Width: 75 Image Length: 92
   Bitdepth (Bits/Sample): 8
   Channels (Samples/Pixel): 1
   Pixel depth (Pixel Depth): 8
   Colour Type (Photometric Interpretation): PALETTED COLOUR (0 colours, 0 transparent)
   Image filter: Single row per byte filter
   Interlacing: No interlacing
   Compression Scheme: Deflate method 8, 32k window
   Resolution: 2834, 2834 (pixels per meter)
   FillOrder: msb-to-lsb
   Byte Order: Network (Big Endian)
   Number of text strings: 0

$ pngcheck -v openlogo-nd-75.with_author_title.with_background.png
zlib warning:  different version (expected 1.2.13, using 1.3.1)
  
File: openlogo-nd-75.with_author_title.with_background.png (1387 bytes)
   chunk IHDR at offset 0x0000c, length 13
     75 x 92 image, 8-bit palette, non-interlaced
   chunk cHRM at offset 0x00025, length 32
     White x = 0.3127 y = 0.329,  Red x = 0.64 y = 0.33
     Green x = 0.3 y = 0.6,  Blue x = 0.15 y = 0.06
   chunk PLTE at offset 0x00051, length 51: 17 palette entries
   chunk bKGD at offset 0x00090, length 1
     index = 0
   chunk pHYs at offset 0x0009d, length 9: 2834x2834 pixels/meter (72 dpi)
   chunk tIME at offset 0x000b2, length 7: 23 Feb 2026 00:43:43 UTC
   chunk IDAT at offset 0x000c5, length 975
     zlib: deflated, 8K window, maximum compression
   chunk tEXt at offset 0x004a0, length 11, keyword: Author
   chunk tEXt at offset 0x004b7, length 37, keyword: date:create
   chunk tEXt at offset 0x004e8, length 37, keyword: date:modify
   chunk tEXt at offset 0x00519, length 40, keyword: date:timestamp
   chunk tEXt at offset 0x0054d, length 10, keyword: Title
   chunk IEND at offset 0x00563, length 0
No errors detected in openlogo-nd-75.with_author_title.with_background.png (13 chunks, 79.9% compression).
$ exiftool -a -G openlogo-nd-75.with_author_title.with_background.png |egrep "^\[(PNG|ExifTool)\]"
[ExifTool]      ExifTool Version Number         : 13.25
[ExifTool]      Warning                         : [minor] Text/EXIF chunk(s) found after PNG IDAT (may be ignored by some readers) [x5]
[PNG]           Image Width                     : 75
[PNG]           Image Height                    : 92
[PNG]           Bit Depth                       : 8
[PNG]           Color Type                      : Palette
[PNG]           Compression                     : Deflate/Inflate
[PNG]           Filter                          : Adaptive
[PNG]           Interlace                       : Noninterlaced
[PNG]           White Point X                   : 0.3127
[PNG]           White Point Y                   : 0.329
[PNG]           Red X                           : 0.64
[PNG]           Red Y                           : 0.33
[PNG]           Green X                         : 0.3
[PNG]           Green Y                         : 0.6
[PNG]           Blue X                          : 0.15
[PNG]           Blue Y                          : 0.06
[PNG]           Palette                         : (Binary data 51 bytes, use -b option to extract)
[PNG]           Background Color                : 0
[PNG]           Pixels Per Unit X               : 2834
[PNG]           Pixels Per Unit Y               : 2834
[PNG]           Pixel Units                     : meters
[PNG]           Modify Date                     : 2026:02:23 00:43:43
[PNG]           Author                          : utor
[PNG]           Datecreate                      : 2026-02-23T00:41:13+00:00
[PNG]           Datemodify                      : 2026-02-23T00:41:13+00:00
[PNG]           Datetimestamp                   : 2026-02-23T00:43:43+00:00
[PNG]           Title                           : itel

Notice that pnginfo no longer reports the iTXt chunks. pngcheck reports tEXt chunks instead.  Exiftool reports the author and title, but the information there is garbage: “utor” for the author and “itel” for the title. Moreover, exiftool warns about Text/EXIF chunk(s) found after PNG IDAT.

We may try an alternative to `-background white`:

$ magick openlogo-nd-75.with_author_title.png -set png:bKGD "#FFFFFF" openlogo-nd-75.with_author_title.with_bKGD.png
$ pnginfo openlogo-nd-75.with_author_title.with_bKGD.png
openlogo-nd-75.with_author_title.with_bKGD.png...
   Image Width: 75 Image Length: 92
   Bitdepth (Bits/Sample): 8
   Channels (Samples/Pixel): 1
   Pixel depth (Pixel Depth): 8
   Colour Type (Photometric Interpretation): PALETTED COLOUR (0 colours, 0 transparent)
   Image filter: Single row per byte filter
   Interlacing: No interlacing
   Compression Scheme: Deflate method 8, 32k window
   Resolution: 2834, 2834 (pixels per meter)
   FillOrder: msb-to-lsb
   Byte Order: Network (Big Endian)
   Number of text strings: 0

$ pngcheck -v openlogo-nd-75.with_author_title.with_bKGD.png
zlib warning:  different version (expected 1.2.13, using 1.3.1)
  
File: openlogo-nd-75.with_author_title.with_bKGD.png (1387 bytes)
   chunk IHDR at offset 0x0000c, length 13
     75 x 92 image, 8-bit palette, non-interlaced
   chunk cHRM at offset 0x00025, length 32
     White x = 0.3127 y = 0.329,  Red x = 0.64 y = 0.33
     Green x = 0.3 y = 0.6,  Blue x = 0.15 y = 0.06
   chunk PLTE at offset 0x00051, length 51: 17 palette entries
   chunk bKGD at offset 0x00090, length 1
     index = 0
   chunk pHYs at offset 0x0009d, length 9: 2834x2834 pixels/meter (72 dpi)
   chunk tIME at offset 0x000b2, length 7: 23 Feb 2026 00:46:11 UTC
   chunk IDAT at offset 0x000c5, length 975
     zlib: deflated, 8K window, maximum compression
   chunk tEXt at offset 0x004a0, length 11, keyword: Author
   chunk tEXt at offset 0x004b7, length 37, keyword: date:create
   chunk tEXt at offset 0x004e8, length 37, keyword: date:modify
   chunk tEXt at offset 0x00519, length 40, keyword: date:timestamp
   chunk tEXt at offset 0x0054d, length 10, keyword: Title
   chunk IEND at offset 0x00563, length 0
No errors detected in openlogo-nd-75.with_author_title.with_bKGD.png (13 chunks, 79.9% compression).
$ exiftool -a -G openlogo-nd-75.with_author_title.with_bKGD.png |egrep "^\[(PNG|ExifTool)\]"
[ExifTool]      ExifTool Version Number         : 13.25
[ExifTool]      Warning                         : [minor] Text/EXIF chunk(s) found after PNG IDAT (may be ignored by some readers) [x5]
[PNG]           Image Width                     : 75
[PNG]           Image Height                    : 92
[PNG]           Bit Depth                       : 8
[PNG]           Color Type                      : Palette
[PNG]           Compression                     : Deflate/Inflate
[PNG]           Filter                          : Adaptive
[PNG]           Interlace                       : Noninterlaced
[PNG]           White Point X                   : 0.3127
[PNG]           White Point Y                   : 0.329
[PNG]           Red X                           : 0.64
[PNG]           Red Y                           : 0.33
[PNG]           Green X                         : 0.3
[PNG]           Green Y                         : 0.6
[PNG]           Blue X                          : 0.15
[PNG]           Blue Y                          : 0.06
[PNG]           Palette                         : (Binary data 51 bytes, use -b option to extract)
[PNG]           Background Color                : 0
[PNG]           Pixels Per Unit X               : 2834
[PNG]           Pixels Per Unit Y               : 2834
[PNG]           Pixel Units                     : meters
[PNG]           Modify Date                     : 2026:02:23 00:46:11
[PNG]           Author                          : utor
[PNG]           Datecreate                      : 2026-02-23T00:41:13+00:00
[PNG]           Datemodify                      : 2026-02-23T00:41:13+00:00
[PNG]           Datetimestamp                   : 2026-02-23T00:46:11+00:00
[PNG]           Title                           : itel

As you see, the result is as bad as before: Author and Title are garbled.

Also notice that pnginfo doesn't show these tags at all, but pngcheck confirms their presence (now as tEXt and no longer as iTXt). If the file is broken, pngcheck should complain; otherwise pnginfo should show the tags.

Please fix all this.

In the whole toolchain, it seems to me that magick is the culprit; of course, the maintainers may reassign if needed.

An aside: setting a bogus color via `-set png:bKGD` should throw an error (both via a return code and on stderr), but it doesn't:

$ magick openlogo-nd-75.with_author_title.png -set png:bKGD "quite a stupid background" garbage.png
$ echo $?
0

Gratefully,
Peter



More information about the Pkg-gmagick-im-team mailing list