Page 1 of 1

how to remove "Histogram" info in image

Posted: 2016-01-05T03:17:52-07:00
by windy_zhh
I have a png image with the "histogram" info, I use command line identify to display the detail below.

Code: Select all

Image: /root/0f9fa9ffcf62ab770e6fa6d8510cf855.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 460x480+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: 220800
    Red:
      min: 133 (0.521569)
      max: 207 (0.811765)
      mean: 135.145 (0.529981)
      standard deviation: 9.81951 (0.0385079)
      kurtosis: 24.908
      skewness: 4.97794
      entropy: 0.101243
    Green:
      min: 118 (0.462745)
      max: 197 (0.772549)
      mean: 120.312 (0.471812)
      standard deviation: 10.6343 (0.0417032)
      kurtosis: 25.1885
      skewness: 5.00166
      entropy: 0.0955312
    Blue:
      min: 187 (0.733333)
      max: 239 (0.937255)
      mean: 188.467 (0.739085)
      standard deviation: 6.59841 (0.0258761)
      kurtosis: 24.0439
      skewness: 4.88035
      entropy: 0.11042
  Image statistics:
    Overall:
      min: 118 (0.462745)
      max: 239 (0.937255)
      mean: 147.975 (0.580293)
      standard deviation: 9.18423 (0.0360166)
      kurtosis: 200.076
      skewness: 20.4102
      entropy: 0.102398
  Colors: 452
  Histogram:
    207168: (133,118,187) #8576BB srgb(133,118,187)
        96: (134,119,188) #8677BC srgb(134,119,188)
        38: (134,120,188) #8678BC srgb(134,120,188)
       485: (136,121,189) #8879BD srgb(136,121,189)
        10: (136,121,190) #8879BE srgb(136,121,190)
      1142: (138,123,190) #8A7BBE srgb(138,123,190)
        78: (138,123,191) #8A7BBF srgb(138,123,191)
         2: (139,125,191) #8B7DBF srgb(139,125,191)
         5: (139,125,192) #8B7DC0 srgb(139,125,192)
         ...
         12: (206,196,233) #CEC4E9 srgb(206,196,233)
         1: (207,196,236) #CFC4EC srgb(207,196,236)
  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: 460x480+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2016-01-04T17:54:49+08:00
    date:modify: 2016-01-04T17:52:54+08:00
    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: 460, 480
    png:sRGB: intent=0 (Perceptual Intent)
    png:text: 1 tEXt/zTXt/iTXt chunks were found
    signature: d6da1efa7cbdffb5700a1ae77d59afbc4a7cc14f4eafd4277315c7a9d98419e5
    Software: Adobe ImageReady
  Artifacts:
    filename: /root/0f9fa9ffcf62ab770e6fa6d8510cf855.png
    verbose: true
  Tainted: False
  Filesize: 34.8KB
  Number pixels: 221K
  Pixels per second: 110.4GB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.2-8 Q16 x86_64 2015-12-19 http://www.imagemagick.org
If I convert it to a Jpeg image in this way, I got a large result image with the "histogram" info as well.

Code: Select all

convert ~/0f9fa9ffcf62ab770e6fa6d8510cf855.png -quality 100 1.jpg
My question is how to remove the "Histogram" info in the png image when I still set the quality=100?

Re: how to remove "Histogram" info in image

Posted: 2016-01-05T05:24:16-07:00
by snibgo
"identify -verbose" re-calculates histogram data. If a histogram is stored in the file, it is stored as a comment. You can remove comments with

Code: Select all

"-set comment ""
See http://www.imagemagick.org/script/comma ... hp#comment

Re: how to remove "Histogram" info in image

Posted: 2016-01-05T07:20:39-07:00
by windy_zhh
snibgo wrote:"identify -verbose" re-calculates histogram data. If a histogram is stored in the file, it is stored as a comment. You can remove comments with

Code: Select all

"-set comment ""
See http://www.imagemagick.org/script/comma ... hp#comment
Thank you. I tried your method, but it didn't seem to work

Code: Select all

# ./convert -quality 100 -comment "" 0f9fa9ffcf62ab770e6fa6d8510cf855.png 1.jpg
# ./convert -quality 100 -set comment "" 0f9fa9ffcf62ab770e6fa6d8510cf855.png 2.jpg
# ll
total 75108
-rw-r--r--  1 root root   34761 Jan  5 22:07 0f9fa9ffcf62ab770e6fa6d8510cf855.png
-rw-r--r--  1 root root   57021 Jan  5 22:17 1.jpg
-rw-r--r--  1 root root   57021 Jan  5 22:17 2.jpg
I still got large(r than src image) result images.

Re: how to remove "Histogram" info in image

Posted: 2016-01-05T07:42:59-07:00
by snibgo
-set comment should come after the image has been read, eg:

Code: Select all

# ./convert 0f9fa9ffcf62ab770e6fa6d8510cf855.png  -set comment "" -quality 100 2.jpg
As "-quality" applies only to writing the JPG, I've moved that to the end.

Re: how to remove "Histogram" info in image

Posted: 2016-01-05T20:01:06-07:00
by windy_zhh
snibgo wrote:-set comment should come after the image has been read, eg:

Code: Select all

# ./convert 0f9fa9ffcf62ab770e6fa6d8510cf855.png  -set comment "" -quality 100 2.jpg
As "-quality" applies only to writing the JPG, I've moved that to the end.
I tried it again, but it still didn't work.

Code: Select all

# ./convert 0f9fa9ffcf62ab770e6fa6d8510cf855.png -set commont "" -quality 100 3.jpg
# ll
total 75164
-rw-r--r--  1 root root   34761 Jan  5 22:07 0f9fa9ffcf62ab770e6fa6d8510cf855.png
-rw-r--r--  1 root root   57021 Jan  5 22:17 1.jpg
-rw-r--r--  1 root root   57021 Jan  5 22:17 2.jpg
-rw-r--r--  1 root root   57021 Jan  6 10:56 3.jpg
I wonder if lossless jpeg image did larger than png image with the same content?

Re: how to remove "Histogram" info in image

Posted: 2016-01-05T20:07:12-07:00
by fmw42
PNG has its own compression and perhaps is doing a better job than JPEG with -quality 100. See http://www.imagemagick.org/script/comma ... hp#quality for PNG compression settings.

JPEG size also may be dependent upon the sampling-factor. See http://www.imagemagick.org/script/comma ... ing-factor

I am not sure that the histogram is stored in the image meta data, but is likely computed on the fly when using identify -verbose.