Last active
February 17, 2018 15:52
-
-
Save pirafrank/aaf3fc68134c58491e521d4403759462 to your computer and use it in GitHub Desktop.
compress images to 85% quality (great quality/size ratio) using image_magick. Great to add DSLR pics to iCloud Photo Sync or similar services and save space.
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 | |
WORKDIR="${1%/}" | |
cd "$WORKDIR" | |
if [[ ! ./ -ef $WORKDIR ]]; then | |
echo "Error: cannot open given dir ($WORKDIR). Exiting..." | |
exit 1 | |
fi | |
# creating ./output folder as subdir of input | |
mkdir "$WORKDIR"/output | |
if [ ! -d "$WORKDIR"/output ];then | |
echo "Error: cannot create output folder. Exiting..." | |
exit 1 | |
fi | |
# shrinking image and setting modification date to shot time | |
for f in *.jpg *.JPG *.jpeg *.JPEG | |
do | |
echo "Processing $f ..." | |
fullname=$(basename "$f") | |
extension="${fullname##*.}" | |
filename="${fullname%.*}" | |
convert -format "jpg" -quality 85 $f output/"$filename""_lite.""$extension" | |
exiftool "-filemodifydate<datetimeoriginal" output/"$filename""_lite.""$extension" | |
#exiftool -overwrite_original_in_place -tagsFromFile $f output/"$filename""_lite.""$extension" | |
done | |
### output exif data to shell | |
# identify -format "%[EXIF:*]" $SOURCE | |
# exiftool -s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment