Skip to content

Instantly share code, notes, and snippets.

@kylekyle
Last active May 10, 2019 03:02
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/2b934e1484e0b53c1bdf518b930a6075 to your computer and use it in GitHub Desktop.
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.
# 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