Created
December 22, 2016 04:45
-
-
Save nhr/530cc0182825f21414fd233765ece050 to your computer and use it in GitHub Desktop.
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.
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
#!/usr/bin/env ruby | |
require 'fastimage' | |
FWIDTH = 1024 | |
FHEIGHT = 600 | |
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}") | |
} | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment