Skip to content

Instantly share code, notes, and snippets.

@detunized
Last active August 29, 2015 13:59
Show Gist options
  • Save detunized/10998857 to your computer and use it in GitHub Desktop.
Save detunized/10998857 to your computer and use it in GitHub Desktop.
Prepare images for printing
#!/usr/bin/env ruby
min_width = `identify *.jpg`
.split("\n")
.map { |i| i[/JPEG (\d+x\d+)/, 1] }
.map { |i| i.split "x" }
.transpose[0]
.map { |i| i.to_i }
.min
p min_width
system "rm -rf print"
system "mkdir -p print"
Dir["*.jpg"].sort_by { |i| i[/\d+/].to_i }.each_slice(4).each_with_index do |images, index|
p images
p index
system %Q{montage -quality 100% -tile 2x2 -geometry 1920x1920+100+539 #{images.join " "} print/cups-#{index}.jpg}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment