?

Log in

No account? Create an account

chunky

« previous entry | next entry »
Feb. 3rd, 2013 | 04:39 pm

Back in September 2012, I needed wanted to look at the internal structure of some PNG files, so I hacked together a utility to read PNGs, digest their chunk structure and display the information gleaned therefrom.

After a couple of days, it did as much as I wanted, and I lost interest, but perhaps it'll be useful to others, so I'm tossing it out here. It's called chunky (groan), and it's currently at version 0.4. The code etc. can be found here (as you can probably tell, I've never gotten into such new-fangled things as version control systems); it's all under the GNU GPL (version 3 or, at your option, any later version).

It should be self-explanatory, but here's the included help text anyway:

Usage: chunky.pl [OPTION]... FILE

Chunk display control options:

    --collapse-chunks=<...>   Collapse specified chunk(s) (default: IDAT, fdAT, mkBT)
    --ignore-chunks=<...>     Ignore the specified chunk(s)
    --ignore-private          Ignore private chunks
    --ignore-unknown          Ignore unknown chunks
    --only-chunks=<...>       Only report the specified chunk(s)
    
Other display control options:

    --round=#                 Round to # decimal places (gAMA, pHYs; default: 1)

Miscellaneous options:

    --help                    Print this help screen
    --license                 Print license text
    --version                 Print version

And here's some example output, using two simple example files and various pony pictures (this, this, this, this, this, this, this and this, not necessarily in that order). The last file examined is an APNG file, BTW.

Processing 1x1.png...
IHDR (13 bytes)
  1x1, grayscale (bitdepth 8), deflate compression, adaptive filtering, Adam7 interlacing
gAMA (4 bytes)
  Gamma: 0.45455 (~1/2.2)
bKGD (2 bytes)
  Background color: (255, 255, 255)
pHYs (9 bytes)
  Pixels per meter^2 (XxY): 2835x2835 (72.0x72.0 dpi)
tIME (7 bytes)
  Last image modification: 2012-09-20 14:07:04 UTC
iTXt (18 bytes)
  Compression: uncompressed, language: none specified
  'Comment: Howdy!'
IDAT (10 bytes)
IEND (0 bytes)

Processing a_new_pet_by_veggie55-d5b6ol1.png...
IHDR (13 bytes)
  1500x4642, truecolor with alpha (bitdepth 8), deflate compression, adaptive filtering, no interlacing
sRGB (1 bytes)
  sRGB color space (IEC 61966-2-1) image, rendering intent: perceptual
bKGD (6 bytes)
  Background color: (0, 0, 0)
pHYs (9 bytes)
  Pixels per meter^2 (XxY): 2835x2835 (72.0x72.0 dpi)
tIME (7 bytes)
  Last image modification: 2012-08-14 16:54:24 UTC
iTXt (29 bytes)
  Compression: uncompressed, language: none specified
  'Comment: Created with GIMP'
IDAT (282 chunks) (2309550 bytes)
IEND (0 bytes)

Processing apple_family__clothed_braeburn__by_applefamily-d567xn6.png...
IHDR (13 bytes)
  10000x5264, truecolor with alpha (bitdepth 8), deflate compression, adaptive filtering, no interlacing
sBIT (4 bytes)
  Significant bits: 8 red, 8 green, 8 blue, 8 alpha
pHYs (9 bytes)
  Pixels per meter^2 (XxY): 9841x9841 (250.0x250.0 dpi)
tEXt (25 bytes)
  'Software: www.inkscape.org'
IDAT (816 chunks) (6680438 bytes)
IEND (0 bytes)

Processing canterlot_wedding_party_poster_by_pixelkitties-d59ycz8.png...
IHDR (13 bytes)
  1900x1236, truecolor with alpha (bitdepth 8), deflate compression, adaptive filtering, no interlacing
pHYs (9 bytes)
  Pixels per meter^2 (XxY): 2835x2835 (72.0x72.0 dpi)
iCCP (2639 bytes)
  Embedded ICC profile: Photoshop ICC profile (deflate compression)
cHRM (32 bytes)
  Referenced white point (CIE 1931 X,Y): (0.31269, 0.32899)
  Red display primary (CIE 1931 X,Y): (0.63999, 0.33001)
  Green display primary (CIE 1931 X,Y): (0.3, 0.6)
  Blue display primary (CIE 1931 X,Y): (0.15, 0.05999)
IDAT (4112627 bytes)
IEND (0 bytes)

Processing coppertone_cutie_mark_crusaders_by_aleximusprime-d56ego0.png...
IHDR (13 bytes)
  1280x907, truecolor (bitdepth 8), deflate compression, adaptive filtering, no interlacing
gAMA (4 bytes)
  Gamma: 0.45455 (~1/2.2)
sRGB (1 bytes)
  sRGB color space (IEC 61966-2-1) image, rendering intent: perceptual
cHRM (32 bytes)
  Referenced white point (CIE 1931 X,Y): (0.3127, 0.329)
  Red display primary (CIE 1931 X,Y): (0.64, 0.33)
  Green display primary (CIE 1931 X,Y): (0.3, 0.6)
  Blue display primary (CIE 1931 X,Y): (0.15, 0.06)
pHYs (9 bytes)
  Pixel aspect ratio (X:Y): 72:72
vpAg (9 bytes)
  Virtual image size: 1280x907 pixel(s)
IDAT (20 chunks) (628282 bytes)
tEXt (37 bytes)
  'date:create: 2012-07-06T20:29:32-07:00'
tEXt (37 bytes)
  'date:modify: 2012-07-06T20:29:32-07:00'
tEXt (26 bytes)
  'Software: Paint.NET v3.5.10'
IEND (0 bytes)

Processing love_that_glows_by_blitzpony-d5dbpht.png...
IHDR (13 bytes)
  882x766, truecolor (bitdepth 8), deflate compression, adaptive filtering, no interlacing
sRGB (1 bytes)
  sRGB color space (IEC 61966-2-1) image, rendering intent: perceptual
gAMA (4 bytes)
  Gamma: 0.45455 (~1/2.2)
pHYs (9 bytes)
  Pixels per meter^2 (XxY): 3779x3779 (96.0x96.0 dpi)
IDAT (22 chunks) (1414404 bytes)
IEND (0 bytes)

Processing pink.png...
IHDR (13 bytes)
  2048x2048, indexed color (bitdepth 1), deflate compression, adaptive filtering, no interlacing
pHYs (9 bytes)
  Pixels per meter^2 (XxY): 2835x2835 (72.0x72.0 dpi)
iTXt (12 bytes)
  Compression: uncompressed, language: none specified
  'Comment: '
PLTE (3 bytes)
  1 color in palette
IDAT (532 bytes)
IEND (0 bytes)

Processing rarity__s_dress_by_blueaugen-d5cs8oh.png...
IHDR (13 bytes)
  800x700, truecolor with alpha (bitdepth 8), deflate compression, adaptive filtering, no interlacing
bKGD (6 bytes)
  Background color: (255, 255, 255)
pHYs (9 bytes)
  Pixel aspect ratio (X:Y): 72:72
vpAg (9 bytes)
  Virtual image size: 800x700 pixel(s)
IDAT (4 chunks) (129621 bytes)
zTXt (46 bytes)
  Compression: deflate
  'create-date: 2012-08-27T13:10:55-07:00'
zTXt (46 bytes)
  Compression: deflate
  'modify-date: 2012-08-27T13:10:55-07:00'
IEND (0 bytes)

Processing tumblr_ma155yFhIv1r3xauuo1_1280.png...
IHDR (13 bytes)
  600x1412, indexed color (bitdepth 8), deflate compression, adaptive filtering, no interlacing
gAMA (4 bytes)
  Gamma: 0.45 (~1/2.2)
tEXt (25 bytes)
  'Software: Adobe ImageReady'
PLTE (768 bytes)
  256 colors in palette
IDAT (242307 bytes)
IEND (0 bytes)

Processing twilight_rapidash_shaded_and_animated_by_tamalesyatole-d5bz7hd.png...
IHDR (13 bytes)
  1175x900, truecolor with alpha (bitdepth 8), deflate compression, adaptive filtering, no interlacing
acTL (8 bytes)
fcTL (26 bytes)
IDAT (22 chunks) (173203 bytes)
fcTL (26 bytes)
fdAT (23 chunks) (185203 bytes)
fcTL (26 bytes)
fdAT (24 chunks) (194498 bytes)
fcTL (26 bytes)
fdAT (25 chunks) (197840 bytes)
fcTL (26 bytes)
fdAT (25 chunks) (204613 bytes)
fcTL (26 bytes)
fdAT (26 chunks) (212509 bytes)
fcTL (26 bytes)
fdAT (27 chunks) (217825 bytes)
fcTL (26 bytes)
fdAT (28 chunks) (225878 bytes)
fcTL (26 bytes)
fdAT (28 chunks) (227440 bytes)
fcTL (26 bytes)
fdAT (29 chunks) (231197 bytes)
fcTL (26 bytes)
fdAT (30 chunks) (238514 bytes)
fcTL (26 bytes)
fdAT (32 chunks) (262012 bytes)
fcTL (26 bytes)
fdAT (34 chunks) (275903 bytes)
fcTL (26 bytes)
fdAT (36 chunks) (290867 bytes)
fcTL (26 bytes)
fdAT (36 chunks) (293899 bytes)
fcTL (26 bytes)
fdAT (34 chunks) (276078 bytes)
fcTL (26 bytes)
fdAT (34 chunks) (275808 bytes)
IEND (0 bytes)

Maybe someone'll find it useful. And if you're going to improve it (yeah, fat chance)... by all means, send me patches. :)

Link | Leave a comment | Share

Comments {0}