Skip to content

PNG files are exported with 2 extra 00 bytes at the end. #1201

@steveschnepp

Description

@steveschnepp

A fresh exported file is :

$ xxd.exe New\ Piskel.png 
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452  .PNG........IHDR
00000010: 0000 0010 0000 0010 0806 0000 001f f3ff  ................
00000020: 6100 0000 5249 4441 5438 4f63 64a0 1030  a...RIDAT8Ocd..0
00000030: 52a8 9f81 6606 fc07 ba8c 28c3 b129 225a  R...f.....(..)"Z
00000040: 33c8 fbe8 06a0 6b06 f1b1 a983 071d 2103  3.....k.......!.
00000050: 400a f11a 82cd 0062 5c86 d305 3009 645b  @......b\...0.d[
00000060: 4972 017a b220 18a0 4445 15be c436 6a00  Ir.z. ..DE...6j.
00000070: 91e9 1d5f 2002 006f de0b 1198 4bbf 8300  ..._ ..o....K...
00000080: 0000 0049 454e 44ae 4260 8200 00         ...IEND.B`...

One can notire the 2 extra 00 after 44ae 4260 82.

Using OptiPNG fixed it.

$ optipng.exe -nb -nc -np -nx -v -fix New\ Piskel.png
OptiPNG version 0.7.8
Copyright (C) 2001-2023 Cosmin Truta and the Contributing Authors.

** Processing: New Piskel.png
Warning: Extraneous data found after IEND
16x16 pixels, 4x8 bits/pixel, RGB+alpha
Recoverable errors found in input. Fixing...
Input IDAT size = 82 bytes
Input file size = 139 bytes

Trying:
  zc = 9  zm = 8  zs = 0  f = 0         IDAT size = 42
  zc = 9  zm = 8  zs = 1  f = 0         IDAT size = 42
  zc = 1  zm = 8  zs = 2  f = 0         IDAT too big
  zc = 9  zm = 8  zs = 3  f = 0         IDAT too big
  zc = 9  zm = 8  zs = 0  f = 5         IDAT too big
  zc = 9  zm = 8  zs = 1  f = 5         IDAT too big
  zc = 1  zm = 8  zs = 2  f = 5         IDAT too big
  zc = 9  zm = 8  zs = 3  f = 5         IDAT too big

Selecting parameters:
  zc = 9  zm = 8  zs = 1  f = 0         IDAT size = 42

Output IDAT size = 42 bytes (40 bytes decrease)
Output file size = 99 bytes (40 bytes = 28.78% decrease)

** Status report
1 file(s) have been processed.
1 error(s) have been encountered.
1 erroneous file(s) have been fixed.

The file doesn't contain any extra data in the end.

$ xxd.exe 'New Piskel.png'
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452  .PNG........IHDR
00000010: 0000 0010 0000 0010 0806 0000 001f f3ff  ................
00000020: 6100 0000 2a49 4441 5438 cb63 6018 b6e0  a...*IDAT8.c`...
00000030: ffa0 d1fc 9f54 03ff e310 fb4f 8a01 ffa9  .....T.....O....
00000040: e12d 6483 fe53 122e ff19 46c1 1000 0032  .-d..S....F....2
00000050: e90f f147 8eb3 e500 0000 0049 454e 44ae  ...G.......IEND.
00000060: 4260 82                                  B`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions