Skip to content

Instantly share code, notes, and snippets.

@dewittpe
Created January 19, 2022 00:15
Show Gist options
  • Save dewittpe/86a661dd2f70a124d73fffe9e49ba8f3 to your computer and use it in GitHub Desktop.
Save dewittpe/86a661dd2f70a124d73fffe9e49ba8f3 to your computer and use it in GitHub Desktop.
Convert a large set of raw image files into a pdf for easy printing
#!/bin/bash
# requires imagemagick
#########################################################
# Unzip a large set of NEF, JEPG, and other image files #
# resize and convert to pdf for easy printing #
#########################################################
# unzip the compressed zip achieves
for i in *.zip;
do
unzip -j -d images $i
done
# move the jpg files to a seperate folder
mkdir jpegs
mv images/*.JPG jpegs
mv images/*.jpg jpegs
# move all the file names to lower case. The zip files contain NEF, JPG, and
# jpg file.
cd jpegs
for i in ./*
do
mv $i `echo $i | tr 'A-Z' 'a-z'`
done
cd ../images
for i in ./*
do
mv $i `echo $i | tr 'A-Z' 'a-z'`
done
# create jpg versions of each of the raw files
for i in ./*.nef
do
sips -s format jpeg $i --out "${i%.*}.jpg"
done
# reduce size of the image files
for i in ./*.jpg
do
convert -monitor -scale 10% $i $i
done
cd ../jpegs
for i in ./p04*.jpg
do
convert -monitor -scale 10% $i $i
done
for i in ./photo*.jpg
do
convert -monitor -scale 10% $i $i
done
# move all the jpegs into one dir
mv -v ../images/*.jpg .
# covert from jpg to pdf -- requires imagemagick
convert -monitor *.jpg images.pdf
# move the images.pdf file to the folder root
cd ..
mv jpegs/images.pdf .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment