Created
November 21, 2010 08:45
-
-
Save hitode909/708578 to your computer and use it in GitHub Desktop.
画像をKindle用にトリミング,リサイズ,ガンマ調整
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 | |
def suffix(file, suffix) | |
base = File.basename(file, File.extname(file)) | |
ext = File.extname(file) | |
"#{base}#{suffix}#{ext}" | |
end | |
banner = <<EOF | |
usage | |
trimming_for_kindle.rb *.jpg | |
EOF | |
if ARGV.empty? | |
puts banner | |
exit(1) | |
end | |
ARGV.each{|file| | |
puts file | |
info = `identify #{file}` | |
size = info.scan(/\d+(?:x)\d+/).first | |
w, h = *size.split(/x/) | |
w = w.to_i | |
h = h.to_i | |
system "mogrify -crop #{w-40}x#{h-40}+20+20 #{file}" or exit | |
system "mogrify -fuzz 15% -trim #{file}" or exit | |
system "mogrify -gamma 0.3 -resize 560x742 #{file}" or exit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment