Last active
May 10, 2019 03:02
-
-
Save kylekyle/2b934e1484e0b53c1bdf518b930a6075 to your computer and use it in GitHub Desktop.
Make your pictures compatible with the Polaroid Pogo. And preview what they will look like. And add cute white borders.
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 printing on a Polaroid Pogo | |
require 'mini_magick' | |
pogo_path = File.join(Dir.pwd,'pogo') | |
Dir.mkdir pogo_path unless File.exists? pogo_path | |
ARGV.each_with_index do |path,i| | |
next if File.directory? path | |
puts "Processing #{path} ..." | |
image = MiniMagick::Image.open(path) | |
geometry = image.data["pageGeometry"] | |
border = 35 | |
width, height = (640 - 2*border), (960 - 2*border) | |
# resize to pogo resolution | |
image.combine_options do |option| | |
option.gravity 'center' | |
if geometry['width'] < geometry['height'] | |
option.thumbnail "#{width}x#{height}^" | |
option.extent "#{width}x#{height}" | |
else | |
option.thumbnail "#{height}x#{width}^" | |
option.extent "#{height}x#{width}" | |
end | |
end | |
# Pogo only accepts jpgs | |
image.format('jpg') | |
# add an adorable border | |
image.border(border) | |
image.bordercolor 'white' | |
# use a short filename or the pogo won't take it | |
image.write(File.join(pogo_path,i.to_s)+".jpg") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment