Last active
January 22, 2025 08:43
-
-
Save daz/474f7816944e31374d28f5208d3ec8a3 to your computer and use it in GitHub Desktop.
Prepare 360 photo for Facebook with max resolution
This file contains hidden or 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 | |
# Max settings, working Jan 2025 | |
MAX_WIDTH=16384 | |
MAX_FILESIZE_KB=16000 | |
# Display help if --help or no arguments are provided | |
if [ "$#" -eq 0 ] || [ "$1" = "--help" ]; then | |
echo "Usage: $0 equirectangular_360_image.jpg" | |
echo "" | |
echo "Resizes the input equirectangular image to the maximum resolution" | |
echo "and file size allowed by Facebook, adds 360 metadata, and saves a copy." | |
echo "" | |
echo "Options:" | |
echo " --help Displays this help message." | |
echo "" | |
echo "Example:" | |
echo " $0 my_360_photo.jpg" | |
exit 0 | |
fi | |
FILE=$1 | |
FILENAME="${FILE%%.*}" | |
EXT="${FILE##*.}" | |
NEW_FILE="${FILENAME}_fb.$EXT" | |
echo "Resizing uniformly to max width $MAX_WIDTH pixels..." | |
magick "$FILE" -resize "${MAX_WIDTH}x" "$NEW_FILE" | |
echo "Reducing max file size to ${MAX_FILESIZE_KB}kb..." | |
magick "$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 with 360 metadata and max resolution/file size for Facebook." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment