Guest User

Untitled

a guest
Jan 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require "fileutils"
  3.  
  4. (puts "Usage: #{File.basename $0} widthxheight"; exit 0) if ARGV.size != 1
  5. width, height = ARGV[0].split("x").collect(&:to_i)
  6. (puts "Please enter a valid size."; exit 0) if ((width.to_i == 0) or (height.to_i == 0))
  7. half_width = width / 2
  8.  
  9. FileUtils.cd("images") do
  10. Dir['**/*'].each do |f|
  11. next if f == "split_image.rb"
  12. puts "Done processing #{f}."
  13. name = File.basename(f).split('.')[0]
  14. system("convert -crop #{half_width}x#{height}+0+0 #{name}.jpeg #{name}-1.jpg")
  15. system("convert -crop #{half_width}x#{height}+#{half_width}+0 #{name}.jpeg #{name}-2.jpg")
  16. system("mv #{name}.jpeg ../images2")
  17. end
  18. end
Add Comment
Please, Sign In to add comment