Converting a JPG to BMP with exact specs - image

I'm trying to alter the displayed boot splash of an AMLogic device (using this tool: https://github.com/steeve/aml-imgpack). I have a JPG which I convert to BMP, as the device needs (let's say https://unsplash.com/photos/SnXIF8_2oPw) but the colors are completely wrong, the image is broken in "lines" and some parts from left are to the right (a bit like repeating the image, but not completely).
The original image, have the following attributes:
$ magick identify -verbose ../original/bootup.bmp
Image:
Filename: ../original/bootup.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 1920x1080+0+0
Resolution: 28.34x28.34
Print size: 67.7488x38.1087
Units: PixelsPerCentimeter
Colorspace: sRGB
Type: TrueColor
Base type: Undefined
Endianness: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Channel statistics:
Pixels: 2073600
Red:
min: 0 (0)
max: 255 (1)
mean: 4.64305 (0.018208)
standard deviation: 31.5717 (0.12381)
kurtosis: 47.4739
skewness: 6.93758
entropy: 0.0513943
Green:
min: 0 (0)
max: 255 (1)
mean: 3.77976 (0.0148226)
standard deviation: 26.4192 (0.103605)
kurtosis: 55.8096
skewness: 7.40689
entropy: 0.0502694
Blue:
min: 0 (0)
max: 239 (0.937255)
mean: 1.81429 (0.00711485)
standard deviation: 13.2764 (0.0520643)
kurtosis: 84.5432
skewness: 8.63456
entropy: 0.0528362
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 3.41236 (0.0133818)
standard deviation: 23.7558 (0.0931598)
kurtosis: 67.5353
skewness: 8.07788
entropy: 0.0515
Rendering intent: Perceptual
Chromaticity:
red primary: (0,0)
green primary: (0,0)
blue primary: (0,0)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1920x1080+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Convex hull: 931,391 932,391 1111,432 1223,484 1230,488 1247,544 1247,549 1244,551 1015,623 919,623 704,551 688,471 688,448 696,432 931,391
Minimum bounding box: 1247,391 1247,623 688,623 688,391
Properties:
date:create: 2020-10-31T22:40:38+00:00
date:modify: 2020-10-31T22:40:38+00:00
minimum-bounding-box:_p: 931,391
minimum-bounding-box:_q: 932,391
minimum-bounding-box:_v: 1015,623
minimum-bounding-box:angle: 0
minimum-bounding-box:area: 129688
minimum-bounding-box:height: 559
minimum-bounding-box:unrotate: -0
minimum-bounding-box:width: 232
signature: 31151e021e5d4cdde8d345165d8eb9cd6489f307272c8ca455d038002885d405
Artifacts:
verbose: true
Tainted: False
Filesize: 3.95515MiB
Number pixels: 2073600
Pixels per second: 79.4977MP
User time: 0.020u
Elapsed time: 0:01.026
Version: ImageMagick 7.0.10-30 Q16 x86_64 2020-09-20 https://imagemagick.org
I tried to convert using:
$ mogrify -format bmp ../new_bootup.jpg
$ mogrify -format bmp -type TrueColor ../new_bootup.jpg
$ mogrify -format bmp -define bmp:subtype=RGB565 ../new_bootup.jpg
but the image did not show correctly. The question is: which flags should I use (or which tool should I use) to achieve as close relpication of the original attributes as possible?

Related

Images with the same resolution, same pixel quantity but one is 3X larger than the other

I'm processing two images from a HTML5 canvas, exporting it into a base64 using toDataUrl() and generating those images files, they have the same amount of pixels and same resolution, but one image file has 3x size than the other one.
Here is the Small sized image(1MB):
And here is the one with big size(3MB):
As you can see, the only difference is the black dots in the grid.
Here are the image magick's indentify verbose output.
To the non-dotted image:
Image: pontoSem.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 1805x1520+0+0
Resolution: 72x72
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 2743600
Red:
min: 0 (0)
max: 255 (1)
mean: 239.227 (0.938144)
standard deviation: 50.1041 (0.196486)
kurtosis: 9.08055
skewness: -3.19968
Green:
min: 0 (0)
max: 255 (1)
mean: 241.654 (0.947662)
standard deviation: 44.0232 (0.17264)
kurtosis: 9.84544
skewness: -3.28708
Blue:
min: 0 (0)
max: 255 (1)
mean: 239.038 (0.937403)
standard deviation: 50.3878 (0.197599)
kurtosis: 8.93501
skewness: -3.18354
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 239.973 (0.94107)
standard deviation: 48.2611 (0.189259)
kurtosis: 9.42491
skewness: -3.24166
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)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1805x1520+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 100
Orientation: Undefined
Properties:
date:create: 2017-03-02T16:56:35-03:00
date:modify: 2017-03-02T16:52:35-03:00
jpeg:colorspace: 2
jpeg:sampling-factor: 2x2,1x1,1x1
signature: 23b092dd21773df0a63a3fffe8241f9916354e3d29638979d672e9cb91026c25
Artifacts:
filename: pontoSem.jpg
verbose: true
Tainted: False
Filesize: 1.063MB
Number pixels: 2.744M
Pixels per second: 45.73MB
User time: 0.040u
Elapsed time: 0:01.060
Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-02-22
And here is the identify to the largest image (the dotted one)
Image: pontoCom.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 1805x1520+0+0
Resolution: 72x72
Print size: 25.0694x21.1111
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 2743600
Red:
min: 0 (0)
max: 255 (1)
mean: 239.227 (0.938144)
standard deviation: 50.1041 (0.196486)
kurtosis: 9.08055
skewness: -3.19968
Green:
min: 0 (0)
max: 255 (1)
mean: 241.654 (0.947662)
standard deviation: 44.0232 (0.17264)
kurtosis: 9.84544
skewness: -3.28708
Blue:
min: 0 (0)
max: 255 (1)
mean: 239.038 (0.937403)
standard deviation: 50.3878 (0.197599)
kurtosis: 8.93501
skewness: -3.18354
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 239.973 (0.94107)
standard deviation: 48.2611 (0.189259)
kurtosis: 9.42491
skewness: -3.24166
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)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1805x1520+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 100
Orientation: Undefined
Properties:
date:create: 2017-03-02T16:56:35-03:00
date:modify: 2017-03-02T16:52:35-03:00
jpeg:colorspace: 2
jpeg:sampling-factor: 2x2,1x1,1x1
signature: 23b092dd21773df0a63a3fffe8241f9916354e3d29638979d672e9cb91026c25
Artifacts:
filename: pontoSem.jpg
verbose: true
Tainted: False
Filesize: 1.063MB
Number pixels: 2.744M
Pixels per second: 45.73MB
User time: 0.040u
Elapsed time: 0:01.060
Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-02-22
I just would like to know why the add of some black dots triple the file size, because they have the same number of pixels, and the sape dpi resolution.
Thanks in advice :)
Jpeg format uses some clever tricks to reduce image size with respect to a raw bitmap image. Those techniques have different success depending on the particular image being represented and generally work better when there are no sharp differences between pixels that are close together. The black dots on white background are exactly the kind of thing that makes it difficult.
In the first image, lots of space can be described as "this area is all white" while the second one needs a much longer description mentioning the color of each pixel wherever those black pixels are near, which is almost everywhere
It's due to compression, the white squares on the first image is much more easily compressed than the second image with more randomness, as the image descriptor says it's using JPEG compression.
As most part of the surface area is using this background, it can easily impact in overall size as it compromises the compression algorithm efficiency.

Retrieve content_type and file name from Base64 encoded image string in Rails 4?

The jpeg image was decoded in a string saved in uploaded_io:
uploaded_io = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2....."
In rails 4 app, the image magick library has been installed and gem mini_magick is in Gemfile. From uploaded_io, we need to retrieve content_type, size and file name (no need to resize and manipulation of the image). We tried to use Ruby's base64 module in controller and there is no success (error and what decoded64 returns is not an image file):
require 'base64'
img = Base64.decode64(uploaded_io)
type = img.content_type #error
size = img.size #error
There is a similar post . But the ActiveSupport::Base64 is discontinued in Rails 4 and it can't be applied to Rails 4.
Not speaking Ruby or Rails, I don't really understand your question, but I think you are trying to get information about a base64-encoded image and I can maybe help with that. I am afraid I can only come towards you from the command-line side of things, but hopefully you can Ruby-ize that...
Let's create a little image:
convert -size 50x50 xc:red xc:lime xc:blue +append image.gif
To get information about an image with ImageMagick, you generally use the identify program from the IM suite, like this:
identify -verbose image.gif
Image: image.gif
Format: GIF (CompuServe graphics interchange format)
Mime type: image/gif
Class: PseudoClass
Geometry: 150x50+0+0
Units: Undefined
Type: Palette
Endianess: Undefined
Colorspace: sRGB
Depth: 8/1-bit
Channel depth:
red: 1-bit
green: 1-bit
blue: 1-bit
Channel statistics:
Pixels: 7500
Red:
min: 0 (0)
max: 255 (1)
mean: 85 (0.333333)
standard deviation: 120.208 (0.471405)
kurtosis: -1.5
skewness: 0.707107
entropy: 0.918296
Green:
min: 0 (0)
max: 255 (1)
mean: 85 (0.333333)
standard deviation: 120.208 (0.471405)
kurtosis: -1.5
skewness: 0.707107
entropy: 0.918296
Blue:
min: 0 (0)
max: 255 (1)
mean: 85 (0.333333)
standard deviation: 120.208 (0.471405)
kurtosis: -1.5
skewness: 0.707107
entropy: 0.918296
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 85 (0.333333)
standard deviation: 120.208 (0.471405)
kurtosis: -1.5
skewness: 0.707107
entropy: 0.918296
Colors: 3
Histogram:
2500: ( 0, 0,255) #0000FF blue
2500: ( 0,255, 0) #00FF00 lime
2500: (255, 0, 0) #FF0000 red
Colormap entries: 4
Colormap:
0: (255, 0, 0) #FF0000 red
1: ( 0,255, 0) #00FF00 lime
2: ( 0, 0,255) #0000FF blue
3: ( 0, 0, 0) #000000 black
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)
Background color: red
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 150x50+0+0
Dispose: Undefined
Compression: LZW
Orientation: Undefined
Properties:
date:create: 2015-11-17T10:07:39+00:00
date:modify: 2015-11-17T10:07:39+00:00
signature: 48d1b973cce66f9a19f3b3738773a30f0519438d893cdfff2223e1941589e008
Artifacts:
filename: image.gif
verbose: true
Tainted: False
Filesize: 325B
Number pixels: 7.5K
Pixels per second: 7.5EB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.2-6 Q16 x86_64 2015-11-15 http://www.imagemagick.org
If I want to base64 encode that, I use openssl like this:
openssl enc -base64 -in image.gif
R0lGODlhlgAyAPEAAP8AAAD/AAAA/wAAACH5BAAAAAAALAAAAACWADIAAAL+hI+p
y50Bo5y02juF3rz7D4adQ5YmgqXqKonuC3PnTD/sjbfxzsv1f8oJb73iDogkDZcp
o9OVjC6Y1Mrz+pFqD9VuBAvebLdebzg81pa7Z3Bauq62se9onDq/1pN3Zv65h9S3
9OcUCDQ4VGh0+JMotFjUWPOYE9kzSVOJc8mTObNJ1BnzGRS6MkpaWnKKmvqyytra
9AoV6zBLWxtyi5t7sSvS2/ALHAwyzFBscYycrLBs1ezxDB2dMT1SjXKtky22zdX9
9Q0eDjBOXi5wbpAOsa7Rjv4ez97+HmA/n7+PXx+PH8B1AtP5O9cv4D+DChEOLFdw
3MFwCQkulNiQ4sMXbxG7TdxWEeJFjxlBbszW8drHaiG/FQAAOw==
The point of my post is to show that you can then pump that base64 mess into identify to interpret it, like this:
identify -verbose "data:image/gif;base64,R0lGODlhlgAyAPEAAP8AAAD/AAAA/wAAACH5BAAAAAAALAAAAACWADIAAAL+hI+p
> y50Bo5y02juF3rz7D4adQ5YmgqXqKonuC3PnTD/sjbfxzsv1f8oJb73iDogkDZcp
> o9OVjC6Y1Mrz+pFqD9VuBAvebLdebzg81pa7Z3Bauq62se9onDq/1pN3Zv65h9S3
> 9OcUCDQ4VGh0+JMotFjUWPOYE9kzSVOJc8mTObNJ1BnzGRS6MkpaWnKKmvqyytra
> 9AoV6zBLWxtyi5t7sSvS2/ALHAwyzFBscYycrLBs1ezxDB2dMT1SjXKtky22zdX9
> 9Q0eDjBOXi5wbpAOsa7Rjv4ez97+HmA/n7+PXx+PH8B1AtP5O9cv4D+DChEOLFdw
> 3MFwCQkulNiQ4sMXbxG7TdxWEeJFjxlBbszW8drHaiG/FQAAOw=="
Image:
Base filename: FQAAOw==
Format: GIF (CompuServe graphics interchange format)
Mime type: image/gif
Class: PseudoClass
Geometry: 150x50+0+0
Units: Undefined
Type: Palette
Endianess: Undefined
Colorspace: sRGB
Depth: 8/1-bit
Channel depth:
red: 1-bit
green: 1-bit
blue: 1-bit
Channel statistics:
Pixels: 7500
Red:
min: 0 (0)
max: 255 (1)
mean: 85 (0.333333)
standard deviation: 120.208 (0.471405)
kurtosis: -1.5
skewness: 0.707107
entropy: 0.918296
Green:
min: 0 (0)
max: 255 (1)
mean: 85 (0.333333)
standard deviation: 120.208 (0.471405)
kurtosis: -1.5
skewness: 0.707107
entropy: 0.918296
Blue:
min: 0 (0)
max: 255 (1)
mean: 85 (0.333333)
standard deviation: 120.208 (0.471405)
kurtosis: -1.5
skewness: 0.707107
entropy: 0.918296
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 85 (0.333333)
standard deviation: 120.208 (0.471405)
kurtosis: -1.5
skewness: 0.707107
entropy: 0.918296
Colors: 3
Histogram:
2500: ( 0, 0,255) #0000FF blue
2500: ( 0,255, 0) #00FF00 lime
2500: (255, 0, 0) #FF0000 red
Colormap entries: 4
Colormap:
0: (255, 0, 0) #FF0000 red
1: ( 0,255, 0) #00FF00 lime
2: ( 0, 0,255) #0000FF blue
3: ( 0, 0, 0) #000000 black
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)
Background color: red
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 150x50+0+0
Dispose: Undefined
Compression: LZW
Orientation: Undefined
Properties:
date:create: 2015-11-17T10:12:05+00:00
date:modify: 2015-11-17T10:12:05+00:00
signature: 48d1b973cce66f9a19f3b3738773a30f0519438d893cdfff2223e1941589e008
Artifacts:
filename: data:image/gif;base64,R0lGODlhlgAyAPEAAP8AAAD/AAAA/wAAACH5BAAAAAAALAAAAACWADIAAAL+hI+p
y50Bo5y02juF3rz7D4adQ5YmgqXqKonuC3PnTD/sjbfxzsv1f8oJb73iDogkDZcp
o9OVjC6Y1Mrz+pFqD9VuBAvebLdebzg81pa7Z3Bauq62se9onDq/1pN3Zv65h9S3
9OcUCDQ4VGh0+JMotFjUWPOYE9kzSVOJc8mTObNJ1BnzGRS6MkpaWnKKmvqyytra
9AoV6zBLWxtyi5t7sSvS2/ALHAwyzFBscYycrLBs1ezxDB2dMT1SjXKtky22zdX9
9Q0eDjBOXi5wbpAOsa7Rjv4ez97+HmA/n7+PXx+PH8B1AtP5O9cv4D+DChEOLFdw
3MFwCQkulNiQ4sMXbxG7TdxWEeJFjxlBbszW8drHaiG/FQAAOw==
verbose: true
Tainted: False
Filesize: 325B
Number pixels: 7.5K
Pixels per second: 7.5EB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.2-6 Q16 x86_64 2015-11-15 http://www.imagemagick.org
[1]: http://i.stack.imgur.com/j9Ei0.gif
Or, you can use convert and re-create the image from its base64-encoded state like this:
{ echo "data:image/png;base64,"; openssl enc -base64 -in image.png; } | convert inline:- decoded.gif

Gimp index-colors vs ImageMagick in terms of image size?

I made a small image using imagemagick, this image has only 2 colors (alpha + some other color) so I want to turn in into index-color mode.
Once I finish the image, I run the command
convert file.png +dither -colors 2 file.png
The resulting image is 169 bytes. Now when I open the image with gimp, I make no change, I just export it as .png, over the old image, on the window that says "Export image as PNG" I untick everything, and keep compression level at 9.
The resulting image is 109 bytes. What makes this difference ? At first I thought it would be meta-data or something like that, I tried from imagemagick to use the -strip command, but it kept the image at 169 bytes. So, it it because of the compression algorithm? What compression algorithm does gimp use ? How can I replicate that with imagemagick?
The reason I want to do it with imagemagick is so I can automate the process, as I plan to do this on 100+ images.
EDIT:
Output of identify -verbose imagemagickfile.png
Image: ic_stage.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 176x176+0+0
Units: Undefined
Type: PaletteAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 4-bit
green: 8-bit
blue: 1-bit
alpha: 1-bit
Channel statistics:
Pixels: 30976
Red:
min: 0 (0)
max: 102 (0.4)
mean: 60.0126 (0.235343)
standard deviation: 50.1973 (0.196852)
kurtosis: -1.87106
skewness: -0.359086
entropy: 0.977354
Green:
min: 0 (0)
max: 150 (0.588235)
mean: 88.2538 (0.346093)
standard deviation: 73.8196 (0.289489)
kurtosis: -1.87106
skewness: -0.359086
entropy: 0.977354
Blue:
min: 0 (0)
max: 255 (1)
mean: 150.031 (0.588359)
standard deviation: 125.493 (0.492131)
kurtosis: -1.87106
skewness: -0.359086
entropy: 0.977354
Alpha:
min: 0 (0)
max: 255 (1)
mean: 150.031 (0.588359)
standard deviation: 125.493 (0.492131)
kurtosis: -1.87106
skewness: 0.359086
entropy: 0.977354
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 100.817 (0.395359)
standard deviation: 99.3306 (0.389532)
kurtosis: -1.05614
skewness: 0.476254
entropy: 0.977354
Alpha: none #00000000
Colors: 2
Histogram:
12751: ( 0, 0, 0, 0) #00000000 none
18225: (102,150,255,255) #6696FFFF srgba(102,150,255,1)
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)
Background color: srgba(255,255,255,1)
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 176x176+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2015-10-26T11:27:21+02:00
date:modify: 2015-10-26T11:27:21+02:00
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:IHDR.bit-depth-orig: 2
png:IHDR.bit_depth: 2
png:IHDR.color-type-orig: 3
png:IHDR.color_type: 3 (Indexed)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 176, 176
png:PLTE.number_colors: 3
png:sRGB: intent=0 (Perceptual Intent)
png:tRNS: chunk was found
signature: 219cc9a10e56ed2940dc1d92e37bec98d49d12c1bd5f2adfd2bcc91fd7b56f85
Artifacts:
filename: ic_stage.png
verbose: true
Tainted: False
Filesize: 218B
Number pixels: 31K
Pixels per second: 0B
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.2-0 Q16 x86_64 2015-08-18 http://www.imagemagick.org
Output of identify -verbose gimpfile.png
Image: ic_stage_2.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 176x176+0+0
Units: Undefined
Type: PaletteAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 4-bit
green: 8-bit
blue: 1-bit
alpha: 1-bit
Channel statistics:
Pixels: 30976
Red:
min: 102 (0.4)
max: 255 (1)
mean: 164.981 (0.646985)
standard deviation: 75.296 (0.295278)
kurtosis: -1.87106
skewness: 0.359086
entropy: 0.977354
Green:
min: 150 (0.588235)
max: 255 (1)
mean: 193.222 (0.757735)
standard deviation: 51.6737 (0.202642)
kurtosis: -1.87106
skewness: 0.359086
entropy: 0.977354
Blue:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
entropy: -nan
Alpha:
min: 0 (0)
max: 255 (1)
mean: 150.031 (0.588359)
standard deviation: 125.493 (0.492131)
kurtosis: -1.87106
skewness: 0.359086
entropy: 0.977354
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 179.543 (0.70409)
standard deviation: 77.6019 (0.304321)
kurtosis: 1.86389
skewness: -1.46287
entropy: -nan
Alpha: srgba(255,255,255,0) #FFFFFF00
Colors: 2
Histogram:
18225: (102,150,255,255) #6696FFFF srgba(102,150,255,1)
12751: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
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)
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 176x176+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2015-10-26T11:27:52+02:00
date:modify: 2015-10-26T11:27:52+02:00
png:IHDR.bit-depth-orig: 1
png:IHDR.bit_depth: 1
png:IHDR.color-type-orig: 3
png:IHDR.color_type: 3 (Indexed)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 176, 176
png:PLTE.number_colors: 2
png:sRGB: intent=0 (Perceptual Intent)
png:tRNS: chunk was found
signature: a22844c38c7ef3a612d94c2d3b9d1be29bb9d5e2f897f87c92947946fe6bc868
Artifacts:
filename: ic_stage_2.png
verbose: true
Tainted: False
Filesize: 138B
Number pixels: 31K
Pixels per second: 30.976GB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.2-0 Q16 x86_64 2015-08-18 http://www.imagemagick.org

What does the "16" refer to in "16-bit Bilevel Gray" and "Depth: 16/1-bit"

ImageMagick's identify command line tool provides information on sampled images contained in image files. I'm trying to understand what the "16" means in the context of what it reports back.
I'm pretty sure this is a monochrome image with just one bit of content and one transparency bit per pixel, so I don't understand the role the "16" plays here. Is it that the 1 represents a grey level "value" of 65535 (i.e. all white, in this case)? Or does this have something to do with the 1-bit of content channel and 1-bit of alpha/transparency channel being packed into a 16-bit word?
In non-verbose mode, it reports:
20140123124823096.pdf PDF 1008x612 1008x612+0+0 **16-bit Bilevel Gray** 77.2KB 0.000u 0:00.000
In verbose mode, it reports the following:
Image: 20140123124823096.pdf
Format: PDF (Portable Document Format)
Mime type: application/pdf
Class: DirectClass
Geometry: 1008x612+0+0
Resolution: 72x72
Print size: 14x8.5
Units: Undefined
Type: Bilevel
Base type: Bilevel
Endianess: Undefined
Colorspace: Gray
Depth: 16/1-bit
Channel depth:
gray: 1-bit
alpha: 1-bit
Channel statistics:
Gray:
min: 0 (0)
max: 65535 (1)
mean: 60686.5 (0.926017)
standard deviation: 17153.4 (0.261744)
kurtosis: 8.59646
skewness: -3.25522
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
Colors: 2
Histogram:
45640: ( 0, 0, 0,65535) #000000000000 graya(0,1)
571256: (65535,65535,65535,65535) #FFFFFFFFFFFF graya(255,1)
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)
Background color: graya(255,1)
Border color: graya(223,1)
Matte color: graya(189,1)
Transparent color: graya(0,0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1008x612+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2014-01-23T12:41:20-08:00
date:modify: 2014-01-23T12:41:20-08:00
pdf:HiResBoundingBox: 1008x612+0+0
pdf:Version: PDF-1.4
signature: 94e55396cd1b4dea139dcb39458ada0c904d80810722d7c03a62691d710755ab
Artifacts:
filename: 20140123124823096.pdf
verbose: true
Tainted: True
Filesize: 53.1KB
Number pixels: 617K
Pixels per second: 15.42MB
User time: 0.040u
Elapsed time: 0:01.039
Version: ImageMagick 6.8.7-3 2013-11-20 Q16 http://www.imagemagick.org
Update: It turns out that the information that ImageMagick's tool is reporting is not actually the information about the image in the PDF file, but apparently the information about the image after it's gone through some kind of internal transformation! I looked at the PDF file in a text editor and can see that it's unambiguously a 1-bit-per-pixel monochrome image at 200 dpi (legal size), rather than the 72 dpi image with an alpha channel that ImageMagick was reporting. All that said, I'm still curious as to what the 16 means even in ImageMagick's artificial world.
Here's a description of the image as it actually exists in the PDF:
<</Type/XObject
/Subtype/Image
/Width 2800
/Height 1700
/BitsPerComponent 1
/ColorSpace/DeviceGray
/Filter /CCITTFaxDecode
/DecodeParms <</Columns 2800 /Rows 1700>>
/Length 142719
>>

Can a PNG be encrypted without losing the exif data?

I've been working on this Reddit puzzle:
http://www.reddit.com/r/playitforward/comments/1v6jfh/contest_first_one_to_solve_this_riddle_gets_my/
and most of users in the thread are stumped. Full disclosure, I'd love to win the prize, but by bringing attention to it and asking for assistance, I understand that I lessen my chances, but at this point I want to know what the image says more than anything.
We narrowed down the cyphers to a URL to a text file with PNG exif data, but when opened as a PNG, it turns out corrupted. Could this PNG be encrypted or purposely corrupted in a way to preserve the exif data and what would be the best way to unravel it? Note that the string of numbers and "AK" were explicitly linked to this clue, so I can only assume there is maybe an Asynchronous Key involved or some standard pioneered by Arjen Kampf Lenstra or some Angry Kid behind it all.
Sure, using ImageMagick like this:
# Look at rose image before we start, and its header
identify -verbose rose.jpg
Image: rose.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 3220
Red:
min: 31 (0.121569)
max: 255 (1)
mean: 145.56 (0.570825)
standard deviation: 69.1755 (0.271277)
kurtosis: -1.38839
skewness: 0.139004
entropy: 0.97057
Green:
min: 27 (0.105882)
max: 255 (1)
mean: 89.2475 (0.34999)
standard deviation: 52.4516 (0.205693)
kurtosis: 2.60505
skewness: 1.80798
entropy: 0.869705
Blue:
min: 21 (0.0823529)
max: 255 (1)
mean: 80.4214 (0.315378)
standard deviation: 54.9267 (0.215399)
kurtosis: 2.93861
skewness: 1.9566
entropy: 0.85334
Image statistics:
Overall:
min: 21 (0.0823529)
max: 255 (1)
mean: 105.076 (0.412064)
standard deviation: 59.3109 (0.232592)
kurtosis: 1.24657
skewness: 1.44732
entropy: 0.897872
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)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 70x46+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 92
Orientation: Undefined
Properties:
date:create: 2015-10-04T18:46:03+01:00
date:modify: 2015-10-04T18:46:03+01:00
jpeg:colorspace: 2
jpeg:sampling-factor: 1x1,1x1,1x1
signature: 38a8912b601557d5a377bff360f03804c383c3298b48d9917504b488e8f4152b
Artifacts:
filename: rose.jpg
verbose: true
Tainted: False
Filesize: 2.65KB
Number pixels: 3.22K
Pixels per second: 3.22EB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.1-10 Q32 x86_64 2015-10-02 http://www.imagemagick.org
Now add a comment into the image and encrypt it as encrypted.png:
convert -comment "Freddy frog" rose.jpg -encipher passphrase.txt encrypted.png
Check the header of encrypted image to see if EXIF data and comment and other data are visible within it - yes, they are:
identify -verbose encrypted.png
Image: encrypted.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 3220
Red:
min: 0 (0)
max: 255 (1)
mean: 126.755 (0.497077)
standard deviation: 73.7824 (0.289343)
kurtosis: -1.18047
skewness: 0.0142557
entropy: 0.99254
Green:
min: 0 (0)
max: 255 (1)
mean: 127.937 (0.501712)
standard deviation: 75.0501 (0.294314)
kurtosis: -1.23185
skewness: -0.0233363
entropy: 0.992485
Blue:
min: 0 (0)
max: 255 (1)
mean: 127.594 (0.500368)
standard deviation: 74.64 (0.292706)
kurtosis: -1.22352
skewness: -0.0177342
entropy: 0.992544
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 127.428 (0.499719)
standard deviation: 74.4927 (0.292128)
kurtosis: -1.21239
skewness: -0.00900116
entropy: 0.992523
Rendering intent: Perceptual
Gamma: 0.45455
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)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 70x46+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
cipher:mode: CTR
cipher:nonce: d3d57ca43eacb27a9d72b65ef976923e5b761c7aaaee1d1914d1769ca4834488
cipher:type: AES
comment: Freddy frog <--- comment is visible
date:create: 2015-10-04T18:48:43+01:00
date:modify: 2015-10-04T18:48:43+01:00
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:gAMA: gamma=0.45454544 (See Gamma, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 70, 46
png:sRGB: intent=0 (Perceptual Intent)
png:text: 6 tEXt/zTXt/iTXt chunks were found
signature: 273e3934027f6ffbcf00b3eca7eb0c576d8fd180e87133112ecacd59225986ee
Artifacts:
filename: encrypted.png
verbose: true
Tainted: False
Filesize: 10.1KB
Number pixels: 3.22K
Pixels per second: 3.22EB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.1-10 Q32 x86_64 2015-10-02 http://www.imagemagick.org
Now look at the encrypted image - junk
Decrypt image as decrypted.jpg - looks like a rose to me :-)
convert encrypted.png -decipher passphrase.txt decrypted.jpg

Resources