Skip to content

Instantly share code, notes, and snippets.

@kylekyle
Created March 17, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylekyle/374f49a197f2e8b669b8f09942ab61ad to your computer and use it in GitHub Desktop.
Save kylekyle/374f49a197f2e8b669b8f09942ab61ad to your computer and use it in GitHub Desktop.
Prep pictures for display on a VIEWline widescreen digital picture frame
# Prep pictures for display on a VIEWline widescreen digital picture frame
# - The file types Google Photo dumped out: heic, mov, jpg, mp4
# - To check that you don't have any others:
# > Dir.entries('.').reject{|f| f.start_with? '.'}.map(&:downcase).map{|f| File.extname f}.uniq
# - Recommend doing orientation adjustments before exporting
require 'mini_magick'
require 'securerandom'
files = Dir.entries('.').select do |file|
['.jpg','.heic'].any? {|ext| file.downcase.end_with? ext}
end
# the resolution of the picture frame
width, height = 480, 234
files.each_with_index do |file,index|
puts "Processing #{index}: #{file} ..."
image = MiniMagick::Image.open(file)
geometry = image.data["pageGeometry"]
# resize to picture frame resolution
image.resize "480x234"
# the frame only accepts jpgs
image.format 'jpg'
# save to the picture frame's SD card
# I'm using a random UUID so that pictures appear in a random order
# I could just shuffle then assign a one-up counter, but I want to
image.write(File.join('/Volumes/PICTURES/',SecureRandom.uuid)+".jpg")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment