Created
December 30, 2011 04:01
-
-
Save btedev/1537739 to your computer and use it in GitHub Desktop.
Make a custom Kim Jong Il funeral procession image
This file contains 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
# Create your very own Kim Jong Il funeral magic! | |
# Requires ImageMagick. | |
# OS X: brew install imagemagick | |
# Ubuntu: sudo apt-get install imagemagick | |
# | |
# Background image from Dustin Fenstermacher via http://gawker.com/5871682/give-yourself-a-dictators-funeral-with-this-kim-jong+il-photoshop-template | |
abort 'usage: jongify.rb image_file' unless ARGV.size == 1 | |
original_image = ARGV[0] | |
# D/L the background image | |
unless File.exist?('kimjong.jpg') | |
`curl http://i.imgur.com/yFtW7.jpg > kimjong.jpg` | |
end | |
# Create the mask image | |
unless File.exist?('mask.jpg') | |
`convert -size 960x716 xc: -draw 'polygon 213,53 524,60 524,443 215,451' -negate mask.jpg` | |
end | |
# Resize the source image | |
size = `identify -format "%w,%h" #{original_image}`.split(',') | |
org_width = size[0].to_f | |
org_height = size[1].to_f | |
if org_width > org_height | |
height = 450.0 | |
width = (height * org_width) / org_height | |
else | |
width = 400.0 | |
height = (width * org_height) / org_width | |
end | |
`convert #{original_image} -resize #{width}x#{height} resized_original.jpg` | |
# Create an image of the same size as the background | |
# with the resized original inset | |
unless File.exist?('black.jpg') | |
`convert -size 960x716 canvas:black black.jpg` | |
end | |
`composite -geometry +154+35 resized_original.jpg black.jpg composite_original.jpg` | |
# Create final image | |
parts = original_image.split('.') | |
final_image = parts[-2] + "_jongified." + parts[-1] | |
`composite composite_original.jpg kimjong.jpg mask.jpg #{final_image}` | |
# Clean up tmp images | |
File.delete('composite_original.jpg') | |
File.delete('resized_original.jpg') | |
puts final_image + " created" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment