Last active
January 10, 2016 17:14
-
-
Save sri/c93229f01fba8105d01f to your computer and use it in GitHub Desktop.
Quickly tag event images to send to friends on Mac OS X Raw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# 20-minute hack to share a bunch of images | |
# taken an event with multiple people. | |
# Running this program will create thumbnails | |
# for each image. And then each thumbnail will | |
# be shown in Preview and you'll be asked to enter | |
# tags/names (seperated by spaces) for each one. | |
# Each original photo will be saved in tags/<tag-name> | |
# directory. | |
# Pre-processing: | |
# Create thumbnails for each image so that launching it | |
# would be quicker. Run this in bash. | |
# for img in *.jpg; do t=$(basename $img); echo $img; cp $img ${t%.*}_thumb.jpg; sips -Z 640 ${t%.*}_thumb.jpg; done | |
`mkdir -p tags; mkdir -p processed` | |
Dir['album_dir/*_thumb.jpg'].each do |thumbnail| | |
original = thumbnail.gsub /_thumb/, "" | |
original_base = File.basename original | |
puts original | |
if File.exists?("processed/#{original_base}") | |
puts "skipping..." | |
next | |
end | |
`touch processed/#{original_base}` | |
`open #{thumbnail}` | |
print "#{Time.now} tags > " | |
$stdout.flush | |
input = gets | |
if input.nil? | |
break | |
elsif input == "\n" | |
input = "general" | |
end | |
tags = input.split | |
tags.each do |t| | |
`mkdir -p tags/#{t}` | |
next_count = Dir["tags/#{t}/*"].size + 1 | |
p Dir['tags/#{t}/*'] | |
puts " size of #{t}: #{next_count}" | |
`cp #{original} tags/#{t}/#{next_count}.jpg` | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment