Created
September 19, 2013 19:09
-
-
Save gotmayonase/6628387 to your computer and use it in GitHub Desktop.
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 'rmagick' | |
include Magick | |
[".jpg", ".png", ".gif"].each do |image_extension| | |
`mkdir -p ./left` | |
`mkdir -p ./right` | |
list = ImageList.new(*Dir["**/*#{image_extension}"]) | |
list.each do |image| | |
extension = File.extname(image.filename) | |
basename = File.basename(image.filename, extension) | |
width,height = image.columns, image.rows | |
new_width = width / 2.0 | |
image.crop(0, 0, new_width, height, true).write("./left/#{basename}_left#{extension}") | |
image.crop(new_width, 0, new_width, height, true).write("./right/#{basename}_right#{extension}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment