Skip to content

Instantly share code, notes, and snippets.

@gotmayonase
Created September 19, 2013 19:09
Show Gist options
  • Save gotmayonase/6628387 to your computer and use it in GitHub Desktop.
Save gotmayonase/6628387 to your computer and use it in GitHub Desktop.
#!/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