Skip to content

Instantly share code, notes, and snippets.

@jmuzsik
Last active July 9, 2019 20:59
Show Gist options
  • Save jmuzsik/87e000847874a6dd54f3fbadf5782c96 to your computer and use it in GitHub Desktop.
Save jmuzsik/87e000847874a6dd54f3fbadf5782c96 to your computer and use it in GitHub Desktop.
imagemagick.sh
#!/bin/bash
# Create the folder to store Next Gen images
mkdir ./Images/JP2Files
mkdir ./Images/WebPFiles
mkdir ./Images/JXRFiles
# Go into Image directory for easier understanding
cd Images
# Loop through all images in the Image directory
for file in *; do
# This means, do not run this code on a directory, only on a file (-f)
if [[ -f $file ]]; then
fileName=$(echo $file | cut -d'.' -f 1) # something.jpg -> something
# Conversion to Next Gen formats, using solely imageMagick defaults
# 100 is used as the default generally lessens the quality of the image
convert $file -quality 100 ./WebPFiles/$fileName.webp
convert $file ./JP2Files/$fileName.jp2
convert $file ./JPXFiles/$fileName.jpx
convert $file ./JXRFiles/$fileName.jxr
fi
done
# Go back down
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment