それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

jpeg と png だとどれくらいサイズが変わるのか

jpegpng だとどれくらいサイズが変わるのか

単純に変換だけしたとき。

takuya@DESKTOP-2ALDRO3:/mnt/c/Users/takuya/Desktop$ convert sample.jpg  -quality 100 out.png
takuya@DESKTOP-2ALDRO3:/mnt/c/Users/takuya/Desktop$ convert sample.jpg  -quality 100 out.jpg
takuya@DESKTOP-2ALDRO3:/mnt/c/Users/takuya/Desktop$ ll out*
-rwxrwxrwx 1 takuya takuya 1.2M Aug 21 00:47 out.jpg
-rwxrwxrwx 1 takuya takuya 2.1M Aug 21 00:47 out.png

png は圧倒的に不利なので、「パレット化」する。

convert sample.jpg -strip -define png:compression-level=9 -define png:compression-filter=0 -define png:compression-strategy=0  -type Palette out.png

パレット化するとだいぶ無駄が減る。

ll out.*
-rwxrwxrwx 1 takuya takuya 550K Aug 21 00:49 out.jpg
-rwxrwxrwx 1 takuya takuya 886K Aug 21 01:05 out.png

#!/usr/bin/env ruby

def gen_cmd (level,filter,strategy)
  "convert
  sample.jpg
  -strip -define png:compression-level=#{level}
  -define png:compression-filter=#{filter}
  -define png:compression-strategy=#{strategy}
  -type Palette out.#{level}.#{filter}.#{strategy}.png".gsub(/\n/,'')
  end



(0..9).each{|level|
  (1..5).each{|filter|
    (0..4).each{|strategy|
     cmd = gen_cmd level, filter, strategy
     p cmd
     `#{cmd}`
    }
  }

}

全通り試してみよう

圧縮フィルタを変えていく

同じパレット化でも、これくらいに差が出てくるわけです。

ll out.9.5.0.png out.0.1.0.png
-rwxrwxrwx 1 takuya takuya 2.9M Aug 21 01:33 out.0.1.0.png
-rwxrwxrwx 1 takuya takuya 826K Aug 21 01:38 out.9.5.0.png
2,964,981  out.0.1.0.png
2,964,981  out.0.1.1.png
2,964,981  out.0.1.2.png
2,964,981  out.0.1.3.png
2,964,981  out.0.1.4.png
2,964,981  out.0.2.0.png
2,964,981  out.0.2.1.png
2,964,981  out.0.2.2.png
2,964,981  out.0.2.3.png
2,964,981  out.0.2.4.png
2,964,981  out.0.3.0.png
2,964,981  out.0.3.1.png
2,964,981  out.0.3.2.png
2,964,981  out.0.3.3.png
2,964,981  out.0.3.4.png
2,964,981  out.0.4.0.png
2,964,981  out.0.4.1.png
2,964,981  out.0.4.2.png
2,964,981  out.0.4.3.png
2,964,981  out.0.4.4.png
2,964,981  out.0.5.0.png
2,964,981  out.0.5.1.png
2,964,981  out.0.5.2.png
2,964,981  out.0.5.3.png
2,964,981  out.0.5.4.png
1,328,449  out.1.1.2.png
1,328,449  out.1.2.2.png
1,328,449  out.1.3.2.png
1,328,449  out.1.4.2.png
1,328,449  out.1.5.2.png
1,328,449  out.2.1.2.png
1,328,449  out.2.2.2.png
1,328,449  out.2.3.2.png
1,328,449  out.2.4.2.png
1,328,449  out.2.5.2.png
1,328,449  out.3.1.2.png
1,328,449  out.3.2.2.png
1,328,449  out.3.3.2.png
1,328,449  out.3.4.2.png
1,328,449  out.3.5.2.png
1,328,449  out.4.1.2.png
1,328,449  out.4.2.2.png
1,328,449  out.4.3.2.png
1,328,449  out.4.4.2.png
1,328,449  out.4.5.2.png
1,328,449  out.5.1.2.png
1,328,449  out.5.2.2.png
1,328,449  out.5.3.2.png
1,328,449  out.5.4.2.png
1,328,449  out.5.5.2.png
1,328,449  out.6.1.2.png
1,328,449  out.6.2.2.png
1,328,449  out.6.3.2.png
1,328,449  out.6.4.2.png
1,328,449  out.6.5.2.png
1,328,449  out.7.1.2.png
1,328,449  out.7.2.2.png
1,328,449  out.7.3.2.png
1,328,449  out.7.4.2.png
1,328,449  out.7.5.2.png
1,328,449  out.8.1.2.png
1,328,449  out.8.2.2.png
1,328,449  out.8.3.2.png
1,328,449  out.8.4.2.png
1,328,449  out.8.5.2.png
1,328,449  out.9.1.2.png
1,328,449  out.9.2.2.png
1,328,449  out.9.3.2.png
1,328,449  out.9.4.2.png
1,328,449  out.9.5.2.png
1,128,468  out.1.1.4.png
1,128,468  out.1.2.4.png
1,128,468  out.1.3.4.png
1,128,468  out.1.4.4.png
1,128,468  out.1.5.4.png
1,088,706  out.2.1.4.png
1,088,706  out.2.2.4.png
1,088,706  out.2.3.4.png
1,088,706  out.2.4.4.png
1,088,706  out.2.5.4.png
1,049,337  out.3.1.4.png
1,049,337  out.3.2.4.png
1,049,337  out.3.3.4.png
1,049,337  out.3.4.4.png
1,049,337  out.3.5.4.png
1,016,731  out.4.1.4.png
1,016,731  out.4.2.4.png
1,016,731  out.4.3.4.png
1,016,731  out.4.4.4.png
1,016,731  out.4.5.4.png
1,012,007  out.1.1.3.png
1,012,007  out.1.2.3.png
1,012,007  out.1.3.3.png
1,012,007  out.1.4.3.png
1,012,007  out.1.5.3.png
1,012,007  out.2.1.3.png
1,012,007  out.2.2.3.png
1,012,007  out.2.3.3.png
1,012,007  out.2.4.3.png
1,012,007  out.2.5.3.png
1,012,007  out.3.1.3.png
1,012,007  out.3.2.3.png
1,012,007  out.3.3.3.png
1,012,007  out.3.4.3.png
1,012,007  out.3.5.3.png
1,012,007  out.4.1.3.png
1,012,007  out.4.2.3.png
1,012,007  out.4.3.3.png
1,012,007  out.4.4.3.png
1,012,007  out.4.5.3.png
1,012,007  out.5.1.3.png
1,012,007  out.5.2.3.png
1,012,007  out.5.3.3.png
1,012,007  out.5.4.3.png
1,012,007  out.5.5.3.png
1,012,007  out.6.1.3.png
1,012,007  out.6.2.3.png
1,012,007  out.6.3.3.png
1,012,007  out.6.4.3.png
1,012,007  out.6.5.3.png
1,012,007  out.7.1.3.png
1,012,007  out.7.2.3.png
1,012,007  out.7.3.3.png
1,012,007  out.7.4.3.png
1,012,007  out.7.5.3.png
1,012,007  out.8.1.3.png
1,012,007  out.8.2.3.png
1,012,007  out.8.3.3.png
1,012,007  out.8.4.3.png
1,012,007  out.8.5.3.png
1,012,007  out.9.1.3.png
1,012,007  out.9.2.3.png
1,012,007  out.9.3.3.png
1,012,007  out.9.4.3.png
1,012,007  out.9.5.3.png
988,969    out.5.1.4.png
988,969    out.5.2.4.png
988,969    out.5.3.4.png
988,969    out.5.4.4.png
988,969    out.5.5.4.png
969,534    out.6.1.4.png
969,534    out.6.2.4.png
969,534    out.6.3.4.png
969,534    out.6.4.4.png
969,534    out.6.5.4.png
964,417    out.7.1.4.png
964,417    out.7.2.4.png
964,417    out.7.3.4.png
964,417    out.7.4.4.png
964,417    out.7.5.4.png
958,431    out.8.1.4.png
958,431    out.8.2.4.png
958,431    out.8.3.4.png
958,431    out.8.4.4.png
958,431    out.8.5.4.png
956,071    out.9.1.4.png
956,071    out.9.2.4.png
956,071    out.9.3.4.png
956,071    out.9.4.4.png
956,071    out.9.5.4.png
953,058    out.1.1.0.png
953,058    out.1.1.1.png
953,058    out.1.2.0.png
953,058    out.1.2.1.png
953,058    out.1.3.0.png
953,058    out.1.3.1.png
953,058    out.1.4.0.png
953,058    out.1.4.1.png
953,058    out.1.5.0.png
953,058    out.1.5.1.png
947,009    out.4.1.1.png
947,009    out.4.2.1.png
947,009    out.4.3.1.png
947,009    out.4.4.1.png
947,009    out.4.5.1.png
930,469    out.2.1.0.png
930,469    out.2.1.1.png
930,469    out.2.2.0.png
930,469    out.2.2.1.png
930,469    out.2.3.0.png
930,469    out.2.3.1.png
930,469    out.2.4.0.png
930,469    out.2.4.1.png
930,469    out.2.5.0.png
930,469    out.2.5.1.png
928,669    out.5.1.1.png
928,669    out.5.2.1.png
928,669    out.5.3.1.png
928,669    out.5.4.1.png
928,669    out.5.5.1.png
909,453    out.6.1.1.png
909,453    out.6.2.1.png
909,453    out.6.3.1.png
909,453    out.6.4.1.png
909,453    out.6.5.1.png
905,455    out.7.1.1.png
905,455    out.7.2.1.png
905,455    out.7.3.1.png
905,455    out.7.4.1.png
905,455    out.7.5.1.png
904,646    out.3.1.0.png
904,646    out.3.1.1.png
904,646    out.3.2.0.png
904,646    out.3.2.1.png
904,646    out.3.3.0.png
904,646    out.3.3.1.png
904,646    out.3.4.0.png
904,646    out.3.4.1.png
904,646    out.3.5.0.png
904,646    out.3.5.1.png
897,668    out.8.1.1.png
897,668    out.8.2.1.png
897,668    out.8.3.1.png
897,668    out.8.4.1.png
897,668    out.8.5.1.png
894,594    out.9.1.1.png
894,594    out.9.2.1.png
894,594    out.9.3.1.png
894,594    out.9.4.1.png
894,594    out.9.5.1.png
887,389    out.4.1.0.png
887,389    out.4.2.0.png
887,389    out.4.3.0.png
887,389    out.4.4.0.png
887,389    out.4.5.0.png
873,315    out.5.1.0.png
873,315    out.5.2.0.png
873,315    out.5.3.0.png
873,315    out.5.4.0.png
873,315    out.5.5.0.png
858,641    out.6.1.0.png
858,641    out.6.2.0.png
858,641    out.6.3.0.png
858,641    out.6.4.0.png
858,641    out.6.5.0.png
854,629    out.7.1.0.png
854,629    out.7.2.0.png
854,629    out.7.3.0.png
854,629    out.7.4.0.png
854,629    out.7.5.0.png
848,080    out.8.1.0.png
848,080    out.8.2.0.png
848,080    out.8.3.0.png
848,080    out.8.4.0.png
848,080    out.8.5.0.png
845,454    out.9.1.0.png
845,454    out.9.2.0.png
845,454    out.9.3.0.png
845,454    out.9.4.0.png
845,454    out.9.5.0.png