Created
March 17, 2020 18:34
-
-
Save kylekyle/374f49a197f2e8b669b8f09942ab61ad to your computer and use it in GitHub Desktop.
Prep pictures for display on a VIEWline widescreen digital picture frame
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
# 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