#!/bin/bash
IFS='
'
fpaths=`echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sort`
for file in $fpaths
do
if [ -f "$file" ]; then
base=${file%.*}
ext=${file##*.}
if [[ ( ( "$ext" == "JPG" ) || ( "$ext" == "jpg" ) ) || ( ( "$ext" == "jpeg" ) || ( "$ext" == "JPEG" ) ) ]]; then
cp "$file" "$base-tmp-cpy.jpg"
exifautotran "$base-tmp-cpy.jpg"
jpegtopnm "$base-tmp-cpy.jpg" | pnmtops -noturn | ps2pdf13 -sPAPERSIZE=a4 - "$base.pdf"
rm "$base-tmp-cpy.jpg"
fi
fi
done