Skip to content

Instantly share code, notes, and snippets.

@igor-kamil
igor-kamil / add_watermark.sh
Last active November 13, 2019 12:47 — forked from basilio/gist:1317108
add watermark to all jpg images with imagemagick (command line)
# Create a watermark image (watermark.png) and place in folder
# Run this script on command line. It generates an image-wm.jpg for each image.jpg
for x in *.jpg; do convert $x watermark.png -gravity southeast -geometry +30+30 -composite ${x//.png}-wm.png; done
# Use variant below to overwrite original file
# for x in *.jpg; do convert $x watermark.png -gravity southeast -geometry +30+30 -composite $x; done
@igor-kamil
igor-kamil / pagespeed_optimize_images.sh
Last active November 26, 2019 09:35 — forked from julianxhokaxhiu/pagespeed_optimize_images.sh
Recursively optimize all PNG and JPG files wherever they are from the script position and inner ( based on OPTING, PNGCRUSH, ADVANCECOMP and JPEGOPTIM )
#!/bin/bash
#resize (only larger) first:
find . -maxdepth 5 \( -iname \*.png -o -iname \*.jpg -o -iname \*.jpeg -o -iname \*.bmp \) -exec convert -resize 1500\> -verbose "{}" "{}" \;
#optimize
find . -type f -name "*.png" -o -name "*.PNG" | xargs optipng -nb -nc
find . -type f -name "*.png" -o -name "*.PNG" | xargs advpng -z4
find . -type f -name "*.png" -o -name "*.PNG" | xargs pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow
find . -iname "*.png" -exec pngquant --force --verbose \{} --output \{} \;
find . -type f -iname '*.jpg' -exec jpegoptim --max=85 --strip-all {} +