Sha256: 8455b6fcecba24bf3acf6d830f433bb9f5d9dd300b17e43eea0ea9e505599166

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'mini_magick'

namespace :picturama do
  namespace :resized do

    desc "Generate resized pictures for a given folder or just a single file"
    task :generate, :source do |t, args|
      if File.directory?(args[:source]) || File.exists?(args[:source])
        size = Picturama::config['resized_default_size']
        album = Picturama::Album.new(:folder => args[:source])
        puts "Generating #{album.count_pictures} resized for folder #{args[:source]}..."
        puts "Size: #{size}"
        album.init_resized
        album.pictures.each do |picture|
          unless picture.has_resized?
            pic = MiniMagick::Image.open(picture.path)
            pic.resize "#{size}"
            pic.format "jpg"
            pic.write picture.resized
            puts "Resized picture generated for source #{File.basename(picture.path)}. Target destination #{File.basename(picture.resized)}"
          end
        end
      else
        puts "Error => target destination #{args[:source]} does not exist"
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picturama-1.0.1 lib/tasks/resized.rake
picturama-1.0.0beta lib/tasks/resized.rake