hscc

The personnal website source code of 'Hugo Soucy' <https://hugo.soucy.cc/>. Creates from an homebrewed static website generator.
Log | Files | Refs

commit 532fdaa71e7152f55f8a6b5731615220706abe71
parent 061a33592a76b60ada8296a55c5722eb84426969
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Mon, 28 Dec 2020 13:37:28 -0500

Add scripts to oprtimize images

Diffstat:
Mbin/image | 13++++++++++++-
Abin/optimize-images.sh | 32++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/bin/image b/bin/image @@ -14,4 +14,15 @@ # mogrify -path . -filter Triangle -define filter:support=2 -thumbnail 300 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB "$line" # done < "${1:-/dev/stdin}" -mogrify -path "$3" -filter Triangle -define filter:support=2 -thumbnail "$2" -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB $1 +# mogrify -path "$3" -filter Triangle -define filter:support=2 -thumbnail "$2" -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB $1 + + + +# Recette imagemagick qui me semble OK pour le dithering +# convert source.png -quantize transparent -dither FloydSteinberg -depth 4 -colors 16 out.png + +# Avec en plus une d├ęsaturation +# convert hs0ucy-2018.png -colorspace GRAY -quantize transparent -dither FloydSteinberg -depth 4 -colors 4 out.png + +# L'explication ici semble pas mal +# <https://infoheap.com/imagemagick-convert-compress-image/> diff --git a/bin/optimize-images.sh b/bin/optimize-images.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# script for optimizing images in a directory (recursive) +# pngcrush & jpegtran settings from: +# http://developer.yahoo.com/performance/rules.html#opt_images + +# pngcrush +for png in `find $1 -iname "*.png"`; do + echo "crushing $png ..." + pngcrush -rem alla -reduce -brute "$png" temp.png + + # preserve original on error + if [ $? = 0 ]; then + mv -f temp.png $png + else + rm temp.png + fi +done + +# jpegtran +for jpg in `find $1 -iname "*.jpg"`; do + echo "crushing $jpg ..." + jpegtran -copy none -optimize -perfect "$jpg" > temp.jpg + + # preserve original on error + if [ $? = 0 ]; then + mv -f temp.jpg $jpg + else + rm temp.jpg + fi +done+ \ No newline at end of file