Skip to content

Instantly share code, notes, and snippets.

@daz
Last active January 14, 2024 14:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daz/474f7816944e31374d28f5208d3ec8a3 to your computer and use it in GitHub Desktop.
Save daz/474f7816944e31374d28f5208d3ec8a3 to your computer and use it in GitHub Desktop.
Prepare 360 photo for Facebook with max resolution
#!/bin/sh
# Resizes any equirectangular image down to the max resolution and file size
# that Facebook will allow and adds 360 metadata. Saves copy with _fb appended
# to file name.
#
# Usage:
# ./360-photo-facebook.sh equirectangular_360_image.jpg
# Max settings, working June 2023
max_width=16430
max_filesize_kb=16000
file=$1
filename="${file%%.*}"
ext="${file##*.}"
new_file="${filename}_fb.$ext"
echo "Resizing uniformally to max width $max_width pixels..."
convert "$file" -resize "$max_width"x "$new_file"
echo "Reducing max file size to ${max_filesize_kb}kb..."
convert "$new_file" -strip -define jpeg:extent="$max_filesize_kb"kb "$new_file"
echo "Adding equirectangular metadata..."
exiftool -overwrite_original -quiet -all= -ProjectionType="equirectangular" "$new_file"
echo "\nSaved $new_file!\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment