Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require "fileutils"
- (puts "Usage: #{File.basename $0} widthxheight"; exit 0) if ARGV.size != 1
- width, height = ARGV[0].split("x").collect(&:to_i)
- (puts "Please enter a valid size."; exit 0) if ((width.to_i == 0) or (height.to_i == 0))
- half_width = width / 2
- FileUtils.cd("images") do
- Dir['**/*'].each do |f|
- next if f == "split_image.rb"
- puts "Done processing #{f}."
- name = File.basename(f).split('.')[0]
- system("convert -crop #{half_width}x#{height}+0+0 #{name}.jpeg #{name}-1.jpg")
- system("convert -crop #{half_width}x#{height}+#{half_width}+0 #{name}.jpeg #{name}-2.jpg")
- system("mv #{name}.jpeg ../images2")
- end
- end
Add Comment
Please, Sign In to add comment