Created
July 9, 2019 19:01
-
-
Save jmuzsik/d6d2fb8fa3d3565ad05e0041496055d5 to your computer and use it in GitHub Desktop.
ConvertFiles.sh
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
#!/bin/bash | |
# Create the folder to store Next Gen images | |
mkdir ./Images/JP2Files | |
mkdir ./Images/WebPFiles | |
mkdir ./Images/Placeholders | |
# 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 | |
# # Create placeholder and move to Placeholder folder | |
# # These options are temporary and definitely have room for improvement | |
if [[ $file == *.png ]]; then | |
# -strip gets rid unnecessary metadata | |
# -quality 1 - 100, specifies image quality | |
# -resize creates thumbnail like images 4096@ = 64x64 16384@ 128x128 | |
convert $file -strip -quality 1 -colors 255 -resize 4096@ ./Placeholders/$fileName.png | |
else | |
convert $file -strip -quality 20 -resize 16384@ ./Placeholders/$fileName.jpg | |
fi | |
# Conversion to Next Gen formats, using solely imageMagick defaults | |
convert $file -quality 100 ./WebPFiles/$fileName.webp | |
convert $file ./JP2Files/$fileName.jp2 | |
fi | |
done | |
# Go back down | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment