Skip to content

Instantly share code, notes, and snippets.

@Unitech
Created May 6, 2020 11:42
Show Gist options
  • Save Unitech/a149a1e4219da9b8e8aec426232304fd to your computer and use it in GitHub Desktop.
Save Unitech/a149a1e4219da9b8e8aec426232304fd to your computer and use it in GitHub Desktop.
Image upload to S3 with auto exif rotation, compression and resize and print direct url access
QUALITY='-y -loglevel quiet -q:v 7 -vf scale=1680:-2'
S3_BUCKET='https://BUCKET.s3.eu-west-3.amazonaws.com/'
function upload() {
exiftran -a -i $f
ffmpeg -i $1 $QUALITY /tmp/$1
aws s3 cp /tmp/$1 s3://BUCKET/$2
}
function uploadall() {
if [ -z $1 ]
then
FOLDER='all'
else
FOLDER=$1
fi
declare -a ARRAY
ARRAY=()
for f in *.{JPG,jpg}; do
exiftran -a -i $f
ffmpeg -i $f $QUALITY /tmp/$f
ARRAY+=(/tmp/$f)
done
for ELEMENT in ${ARRAY[@]}
do
aws s3 cp $ELEMENT s3://BUCKET/$FOLDER/
echo $S3_BUCKET$FOLDER/`basename "$ELEMENT"`
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment