Excluded *.svg, *.pdf and extensionless files from low-res photos

in the special thesis submodule.
There is no need to convert pdf, svg to jpeg and shrink even in
thesis draft mode.
master
Taha Ahmed
parent 696c5a2127
commit 0ee110ac18

@ -93,7 +93,7 @@ if [ $# -eq 1 ]; then
echo "<thesis> -------------------------------"
echo "<thesis> Getting external assets"
echo "<thesis> -------------------------------"
# summary of operations in this if-clause:
# summary of operations in this if-clause:
# trawl the assets/ subdirectories looking for a file "external.assets", if found,
# read its contents line-by-line (each line is a path) and copy that file at that path to the current assets/ subdir
# note that we only look for assets.external inside the subdirectories, and not in assets/ itself
@ -150,16 +150,24 @@ if [ $# -eq 1 ]; then
largephototype=${largephotobase#*.} # file extension only
largephotoname=${largephotofilename%.*} # path without extension
largephotobasename=${largephotobase%.*} # basename without extension
if [ ! "$largephototype" == "jpg" ] && [ ! "$largephototype" == "jpeg" ] && [ ! "$largephototype" == "JPG" ] && [ ! "$largephototype" == "JPEG" ]; then
echo "<thesis> Converting $largephotobase to JPG format"
mogrify -format jpg $largephotofilename
# remove the now unnecessary non-jpg file from .lowres/
rm "$largephotofilename"
# some filetypes don't fare well when converted to jpeg, so we will only run the
# forced conversion and shrinking unless the file extension is one of the following:
# "" (empty string, ie no file extension)
# SVG
# PDF
if [ ! "$largephototype" == "" ] || [ ! "$largephototype" == "svg" ] || [ ! "$largephototype" == "SVG" ] || [ ! "$largephototype" == "pdf" ] || [ ! "$largephototype" == "PDF" ]; then
# if the photo is not already jpeg, convert it to jpeg
if [ ! "$largephototype" == "jpg" ] && [ ! "$largephototype" == "jpeg" ] && [ ! "$largephototype" == "JPG" ] && [ ! "$largephototype" == "JPEG" ]; then
echo "<thesis> Converting $largephotobase to JPG format"
mogrify -format jpg $largephotofilename
# remove the now unnecessary non-jpg file from .lowres/
rm "$largephotofilename"
fi
# convert photo in-place (overwrite) with new one roughly 300kb in size
# https://stackoverflow.com/questions/6917219/imagemagick-scale-jpeg-image-with-a-maximum-file-size
echo "<thesis> Shrinking $largephotobasename.jpg"
convert $largephotoname.jpg -define jpeg:extent=300kb $largephotoname.jpg
fi
# convert photo in-place (overwrite) with new one roughly 300kb in size
# https://stackoverflow.com/questions/6917219/imagemagick-scale-jpeg-image-with-a-maximum-file-size
echo "<thesis> Shrinking $largephotobasename.jpg"
convert $largephotoname.jpg -define jpeg:extent=300kb $largephotoname.jpg
done
# update the modification and access time on the photosastrun file
touch "$photoslastrun"

Loading…
Cancel
Save