Strip PNG metadata using Ubuntu 13.11: pngcrush and optipng

PNG optimizing tools reduce size my getting rid of “extra” stuff. Some of that extra stuff is the metadata that can be used to identify who took the picture. I’m no professional metadata-remover, I just did this testing for fun.

sudo apt-get install -y pngcrush libimage-exiftool-perl
pngcrush -rem allb -brute -reduce original.png optimized.png && optipng -o7 optimized.png

pngcrush – run the pngcrush program

-rem allb – remove all extraneous data

-brute – attempt all optimization methods

-reduce – eliminate unused colors and reduce bit-depth 4

original.png – the name of the original (unoptimized) PNG file

optimized.png – the name of the new, optimized PNG file

&& – command #2 will be executed if and only if command #1 returns exit status zero

optipng – run the optipng program

-o7 – optimize the image at the highest possible level

optimized.png – the already pngcrush-optimized PNG file that will be further optimized (if possible) with optipng

Let’s test!

Here’s an image that’s CC-BY-SA from Wikipedia: http://upload.wikimedia.org/wikipedia/commons/8/89/Tenaya_Lake_Yosemite_National_Park.png

pngcrush -rem allb -brute -reduce Tenaya_Lake_Yosemite_National_Park.png Tenaya_Lake_Yosemite_National_Park2.png && optipng -o7 Tenaya_Lake_Yosemite_National_Park2.png

Then to check the metadata:

identify -verbose Tenaya_Lake_Yosemite_National_Park.png

Image: Tenaya_Lake_Yosemite_National_Park.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 2048x1536+0+0
Resolution: 70.87x70.87
Print size: 28.898x21.6735
Units: PixelsPerCentimeter
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 111.14 (0.435842)
standard deviation: 42.8511 (0.168043)
kurtosis: 0.724192
skewness: 1.17595
Green:
min: 0 (0)
max: 255 (1)
mean: 130.885 (0.513273)
standard deviation: 38.549 (0.151173)
kurtosis: -0.384294
skewness: 0.458422
Blue:
min: 0 (0)
max: 255 (1)
mean: 155.366 (0.609278)
standard deviation: 48.5428 (0.190364)
kurtosis: -0.907909
skewness: -0.00882359
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 132.463 (0.519464)
standard deviation: 43.5073 (0.170617)
kurtosis: 0.23089
skewness: 0.637459
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Interlace: None
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 2048x1536+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2014-01-15T19:41:21-08:00
date:modify: 2014-01-15T19:41:21-08:00
png:cHRM : chunk was found (see Chromaticity, above)
png:gAMA : gamma=0.45454544 (See Gamma, above)
png:iCCP : chunk was found
png:IHDR.bit_depth : 8
png:IHDR.color_type : 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height : 2048, 1536
png:pHYs : x_res=7087, y_res=7087, units=1
png:sRGB : intent=0 (See Rendering intent)
signature: 4be08d8b3f54c63739c5653a38dd4f817da97114025dddaccbf7e9e533396d56
Profiles:
Profile-icc: 1352 bytes
Description: Camera RGB Profile
Manufacturer: Camera RGB Profile
Model: Camera RGB Profile
Copyright: Copyright 2003 Apple Computer Inc., all rights reserved.
Artifacts:
filename: Tenaya_Lake_Yosemite_National_Park.png
verbose: true
Tainted: False
Filesize: 4.961MB
Number pixels: 3.146M
Pixels per second: 10.49MB
User time: 0.290u
Elapsed time: 0:01.300
Version: ImageMagick 6.7.7-10 2013-09-10 Q16 http://www.imagemagick.org

And compare the optimized copy:

identify -verbose Tenaya_Lake_Yosemite_National_Park2.png

Image: Tenaya_Lake_Yosemite_National_Park2.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 2048x1536+0+0
Resolution: 72x72
Print size: 28.4444x21.3333
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 111.14 (0.435842)
standard deviation: 42.8511 (0.168043)
kurtosis: 0.724192
skewness: 1.17595
Green:
min: 0 (0)
max: 255 (1)
mean: 130.885 (0.513273)
standard deviation: 38.549 (0.151173)
kurtosis: -0.384294
skewness: 0.458422
Blue:
min: 0 (0)
max: 255 (1)
mean: 155.366 (0.609278)
standard deviation: 48.5428 (0.190364)
kurtosis: -0.907909
skewness: -0.00882359
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 132.463 (0.519464)
standard deviation: 43.5073 (0.170617)
kurtosis: 0.23089
skewness: 0.637459
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Interlace: None
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 2048x1536+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2014-01-15T19:58:34-08:00
date:modify: 2014-01-15T19:58:34-08:00
png:cHRM : chunk was found (see Chromaticity, above)
png:gAMA : gamma=0.45454544 (See Gamma, above)
png:IHDR.bit_depth : 8
png:IHDR.color_type : 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height : 2048, 1536
png:sRGB : intent=0 (See Rendering intent)
signature: 4be08d8b3f54c63739c5653a38dd4f817da97114025dddaccbf7e9e533396d56
Artifacts:
filename: Tenaya_Lake_Yosemite_National_Park2.png
verbose: true
Tainted: False
Filesize: 4.454MB
Number pixels: 3.146M
Pixels per second: 14.98MB
User time: 0.210u
Elapsed time: 0:01.209
Version: ImageMagick 6.7.7-10 2013-09-10 Q16 http://www.imagemagick.org

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s