Last active
February 28, 2020 16:16
-
-
Save msammarco/6839233356ce4742a58ecc0b7b950f6d to your computer and use it in GitHub Desktop.
Fish Shell Image Resizing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### smartresize inputfile.jpeg | |
# Credit goes to https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/ | |
# Resize one image in place either jpg or png | |
function smartresize | |
mogrify -path . -filter Triangle -define filter:support=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 $argv | |
end | |
### smartresize_to_webp_dir image_type_extension | |
# Resize all extension type to webp images in directory to 80% quality | |
# eg. smartresize_to_webp_dir jpg | |
# Credit goes to https://www.smashingmagazine.com/2018/07/converting-images-to-webp/ | |
# See also https://developers.google.com/speed/webp/docs/cwebp | |
function smartresize_to_webp_dir | |
find ./ -type f -name "*."$argv | xargs -P 8 -I {} sh -c 'cwebp -q 80 $1 -o ${1%}.webp' _ {} \; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment