Last active
January 14, 2024 14:36
-
-
Save daz/474f7816944e31374d28f5208d3ec8a3 to your computer and use it in GitHub Desktop.
Prepare 360 photo for Facebook with max resolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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