Skip to content

Instantly share code, notes, and snippets.

@zph
Created April 26, 2012 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zph/2495001 to your computer and use it in GitHub Desktop.
Save zph/2495001 to your computer and use it in GitHub Desktop.
Embed a label in each image based on filename
#!/usr/bin/env ruby
#
# Author: tevic@civet.ws
# Description: Apply a label at the bottom of each photo in folder
# according to filename.
# Dependencies:
# *nix
# Ruby
# ImageMagick
#####################################
#
Dir.glob('*').grep(/jpg$/i).each do |file|
file_orig = File.expand_path(file)
output_name = "#{file.gsub(/\W/, '_')}_labelled.JPG"
puts "Working on #{file_orig}"
`convert '#{file_orig}' -background seashell3 -pointsize 72 label:'#{file.gsub(/-/, '/').gsub(/\.jpg/i, '')}' -gravity Center -append tmp/#{output_name}`
puts "Done with #{file_orig}"
end
# Increase font size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment