Skip to content

Instantly share code, notes, and snippets.

@nhr nhr/framinate.rb
Created Dec 22, 2016

What would you like to do?
This script is useful for rotating & scaling images to a specific native resolution. I wrote it to prep pictures for use with a digital photo frame. I found that it is very hard to automate good cropping, but having everything at the same scale saves a lot of the work.
#!/usr/bin/env ruby
require 'fastimage'
FWIDTH = 1024
workdir = Dir.pwd
Dir.foreach(workdir) { |item|
curritem = File.join(workdir,item)
pre = FastImage.size(curritem)
puts "- #{item} (#{pre[0]}x#{pre[1]})"
system("mogrify -auto-orient -resize \"#{FWIDTH}x#{FHEIGHT}^\" #{curritem}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.