Sha256: f66c83d2d556e7476fa0744cc9ee47b38587c8b88e03fd405b84fc4867149bbc

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

require 'mini_magick'

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picturama-0.0.6 lib/tasks/resized.rake