Unofficial pngcheck now with APNG support

I have extended my pngcheck fork[0] to add APNG support. It now reports 
whether a PNG is static or animated. In non-verbose mode, if there are 
no errors, it also reports the number of frames.

Sample non-verbose output (on the Philip Taylor test suite)[1] - files 
040 to 058 are known to be invalid.

I notice it fails to detect errors in 044 (missing fdAT), will look into 
that.

chris@SuperNomad:/mnt/c/Users/chris/Documents/PNG/philip_APNG_tests_files$ pngcheck -c *.png
OK: 000.png (128x64, 32-bit RGB+alpha, non-interlaced, static, 99.2%).
OK: 001.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (1 frame), 99.1%).
OK: 002.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (1 frame), 98.6%).
OK: 003.png (128x64, 32-bit RGB+alpha, non-interlaced, static, 99.2%).
OK: 004.png (128x64, 32-bit RGB+alpha, non-interlaced, static, 99.2%).
OK: 005.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (1 frame), 98.5%).
OK: 006.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (1 frame), 98.5%).
OK: 007.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (3 frames), 98.1%).
OK: 008.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (3 frames), 98.3%).
OK: 009.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.4%).
OK: 010.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (3 frames), 97.6%).
OK: 011.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.4%).
OK: 012.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.9%).
OK: 013.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (3 frames), 98.1%).
OK: 014.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 99.0%).
OK: 015.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (3 frames), 98.5%).
OK: 016.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (3 frames), 97.9%).
OK: 017.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.0%).
OK: 018.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.4%).
OK: 019.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.1%).
OK: 020.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.2%).
OK: 021.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (128 frames), 12.1%).
OK: 022.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (16 frames), 89.8%).
OK: 023.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (16 frames), 89.4%).
OK: 024.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.4%).
OK: 025.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (4 frames), 96.7%).
OK: 026.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.0%).
OK: 027.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.0%).
OK: 028.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.0%).
OK: 029.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (4 frames), 96.7%).
OK: 030.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.0%).
OK: 031.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.0%).
OK: 032.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.0%).
OK: 033.png (128x64, 64-bit RGB+alpha, non-interlaced, animated (2 frames), 98.6%).
OK: 034.png (128x64, 8-bit grayscale, non-interlaced, animated (2 frames), 96.0%).
OK: 035.png (128x64, 16-bit grayscale+alpha, non-interlaced, animated (2 frames), 95.9%).
OK: 036.png (128x64, 1-bit palette, non-interlaced, animated (2 frames), 74.4%).
OK: 037.png (128x64, 2-bit palette+trns, non-interlaced, animated (2 frames), 85.0%).
OK: 038.png (128x64, 1-bit palette+trns, non-interlaced, animated (2 frames), 73.0%).
OK: 039.png (128x64, 32-bit RGB+alpha, non-interlaced, static, 98.6%).
040.png  multiple acTL not allowed
ERROR: 040.png
041.png  acTL must be before first IDAT
ERROR: 041.png
043.png  sequence numbers must be sequential
ERROR: 043.png
OK: 044.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 98.4%).
045.png  acTL number of frames cannot be zero
ERROR: 045.png
046.png  acTL number of frames cannot be zero
ERROR: 046.png
047.png  Expected 1 frames, but found 2
ERROR: 047.png
048.png  Expected 3 frames, but found 2
ERROR: 048.png
049.png  Expected 4 frames, but found 2
ERROR: 049.png
050.png  Expected 2147483649 frames, but found 1
ERROR: 050.png
051.png  sequence numbers must start at zero
ERROR: 051.png
052.png  sequence numbers must be sequential
ERROR: 052.png
053.png  sequence numbers must be sequential
ERROR: 053.png
054.png  sequence numbers must be sequential
ERROR: 054.png
055.png  sequence numbers must be sequential
ERROR: 055.png
056.png  sequence numbers must be sequential
ERROR: 056.png
057.png  sequence numbers must be sequential
ERROR: 057.png
058.png  First frame is IDAT, so first frame must be same size as static image
ERROR: 058.png
OK: 059.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (1 frame), 98.8%).
OK: 060.png (128x64, 32-bit RGB+alpha, non-interlaced, animated (1 frame), 98.1%).
OK: lime.png (128x64, 24-bit RGB, non-interlaced, static, 99.3%).
OK: underconstruction.png (51x50, 32-bit RGB+alpha, non-interlaced, animated (2 frames), 86.0%).

Errors were detected in 17 of the 62 files tested.
No errors were detected in 45 of the 62 files tested.

Sample verbose output on a single file:

chris@SuperNomad:/mnt/c/Users/chris/Documents/PNG/APNG samples$ pngcheck -c -v 012-dispose-previous.png
File: 012-dispose-previous.png (2669 bytes)
   chunk IHDR at offset 0x0000c, length 13
     200 x 200 image, 32-bit RGB+alpha, non-interlaced
   chunk bKGD at offset 0x00025, length 6
     red = 0x00ff, green = 0x00ff, blue = 0x00ff
   chunk acTL at offset 0x00037, length 8
     Animated PNG, 3 frames, plays continuously
   chunk fcTL at offset 0x0004b, length 26
     Frame, sequence number 0
     Width 200, height 200 starting at (0, 0)
     Frame delay 65537 (65537 / 1) sec
     No disposal before next frame
     Frame composites (source over) with buffer
   chunk IDAT at offset 0x00071, length 1132
     zlib: deflated, 32K window, default compression
   chunk fcTL at offset 0x004e9, length 26
     Frame, sequence number 1
     Width 200, height 200 starting at (0, 0)
     Frame delay 65537 (65537 / 1) sec
     Reverts to previous contents before next frame
     Frame composites (source over) with buffer
   chunk fdAT at offset 0x0050f, length 443
     Frame data, sequence number 2
   chunk fcTL at offset 0x006d6, length 26
     Frame, sequence number 3
     Width 200, height 200 starting at (0, 0)
     Frame delay 65537 (65537 / 1) sec
     No disposal before next frame
     Frame composites (source over) with buffer
   chunk fdAT at offset 0x006fc, length 861
     Frame data, sequence number 4
   chunk IEND at offset 0x00a65, length 0
No errors detected in 012-dispose-previous.png (10 chunks, 98.3% compression).

[0] https://github.com/svgeesus/pngcheck
[1] https://philip.html5.org/tests/apng/tests.html

-- 
Chris Lilley
@svgeesus
Technical Director @ W3C
W3C Strategy Team, Core Web Design
W3C Architecture & Technology Team, Core Web & Media

Received on Monday, 3 February 2025 19:01:02 UTC