for F in public/*/cover.jpg public/*/cover.png do echo Processing: $F B=$(echo $F | sed s/.jpg// | sed s/.png//) D=$(dirname $F) if [ $F -nt $D/thumbnail.jpg ] then PORTRAIT=$(convert $F -format '%[fx:w $B.1x.jpg rm -f $B.1x.png convert -colorspace RGB -resize $SIZE_2X $F -colorspace sRGB $B.2x.png pngtopnm $B.2x.png | cjpeg -progressive -optimize -sample 1x1 -quality 95 > $B.2x.jpg rm -f $B.2x.png convert -colorspace RGB -resize $SIZE_TH $F -colorspace sRGB $D/thumbnail.png pngtopnm $D/thumbnail.png | cjpeg -progressive -optimize -sample 1x1 -quality 95 > $D/thumbnail.jpg rm -f $D/thumbnail.png fi done