1
0
Fork 0
mirror of https://github.com/fmap/muflax65ngodyewp.onion synced 2024-07-02 10:50:42 +02:00
muflax65ngodyewp.onion/commands/images.rb
muflax 6706ea2e73 more transitioning
* use smaller images
* rss fixed
* categories fixed and improved
* basic blog layout
* minor fixes
2012-04-18 02:08:04 +02:00

30 lines
873 B
Ruby

require 'image_size'
usage 'images'
summary 'prepares images'
description 'Prepares images for uploads, i.e. strips them of metadata, compresses them and so on.'
module Nanoc::CLI::Commands
class Images < ::Nanoc::CLI::CommandRunner
def run
img_dir = "content/pigs"
exts = "{" + %w{jpg png gif}.join(",") + "}"
# resize all large images
Dir["#{img_dir}/*.#{exts}"].select {|f| ImageSize.new(IO.read(f)).width > 400}.map do |img|
small_img = img.gsub /^(.+)\.(\w+)$/, '\1_small.\2'
next if File.exists? small_img and File.mtime(small_img) >= File.mtime(img)
puts "resizing #{img}..."
system "convert -resize '400' #{img} #{small_img}"
end
# strip exif
system "exiftool -all= -overwrite_original #{img_dir}/*.#{exts}"
end
end
end
runner Nanoc::CLI::Commands::Images