Facebook 360 View

Facebook 360 View Script

Facebook automatically offers you a 360 View option for any image for which the EXIF data conforms to their expectations. In this episode, I introduce a script to make Facebook recognize your photo as a 360 View panorama.
Thank you Morgan Hardwood for your collaboration on this script, and a big thank-you again to Fatdunky for contributing a RAW that worked so well with the concept – and made me envy you your travels.
Fatdunky's RAW file, along with my sidecar file, are on the Weekly Edit page for this episode. The script is posted there too.
We've also archived the script on our Scripts page for easy reference later
This video is the latest in our faster format but packed with information. It builds on knowledge from previous videos, running full-tilt through tools and methods to achieve the edit. For fuller explanations, return to the Home Page and scroll down to Topics Discussed or Modules Used on the right-hand bar. Click on any of these, and we assemble a complete playlist of every instance from a knowledge base of our first 27 videos for quick review right here on the site.
Thank you for watching!

Script to modify EXIF data

#!/usr/bin/env bash
# Adds metadata to images so that Facebook displays them as panoramas.
# https://discuss.pixls.us/t/panorama-mode-in-facebook/3585
# By Harry Durgin and Morgan Hardwood

if [[ ! -f ${1} ]]; then
    printf '%sn' "No input file specified or file not found." "Aborting."
    exit 1
fi

hfov=0
while [[ hfov -lt 100 || hfov -gt 360 ]]; do
    read -r -p "Enter horizontal field of view (100-360): " hfov
done

for f in "${@}"; do
    printf '%sn' "" "Processing: $f"

    width="$(exiftool -T -ImageWidth "${f}")"
    height="$(exiftool -T -ImageHeight "${f}")"
    ratio=$((width/height))

    if [[ ratio -lt 2 ]]; then
        printf '%sn' "Image must have a ratio of at least 2:1." "Skipping."
        continue
    fi

    width_full=$((360*width/hfov))
    height_full=$((180*width_full/hfov))
    height_full=$((width_full/2))
    left_crop=$(((width_full-width)/2))
    top_crop=$(((height_full-height)/2))

    exiftool 
        -FullPanoWidthPixels="$width_full" 
        -FullPanoHeightPixels="$height_full" 
        -CroppedAreaLeftPixels="$left_crop" 
        -CroppedAreaTopPixels="$top_crop" 
        -CroppedAreaImageWidthPixels="$width" 
        -CroppedAreaImageHeightPixels="$height" 
        -ProjectionType=equirectangular 
        -UsePanoramaViewer=True 
        "$f"
done

One thought on “Facebook 360 View

  1. Pingback: Weekly Edit 34: Facebook 360 View – darktable FR

Leave a Reply

Your email address will not be published.