0

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
TomTsagk
  • 1,474
  • 9
  • 23

0 Answers0