Sha256: 6b1c17b6fd8c803d5b9dde2855a2c9e711a0b7649748219454c1edea4e60bc55
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
module IconGenerator class TouchBuilder include IconGenerator::Validator # Initializes the default image sizes. def initialize @sizes = [ '144x144', '114x114', '72x72', '57x57', ] end # Builds apple-touch-icons from the given source file. # # @param source [String] the source image file # @param destination [String] the output directory def build(source, destination) @sizes.each do |size| new_image = "#{destination}/apple-touch-icon-#{size}-precomposed.png" build_size(source, size, new_image) if size == '57x57' build_size(source, '57x57', "#{destination}/apple-touch-icon-precomposed.png") build_size(source, '57x57', "#{destination}/apple-touch-icon.png") end end end # Builds a given size of apple-touch-icon. # # @param source [String] the source image file # @param size [String] the requested image size, in WxH format # @param new_image [String] the output image def build_size(source, size, new_image) %x[convert '#{source}' -resize #{size}! #{new_image}] validate_file_status new_image puts Thor::Shell::Color.new.set_color("Built #{new_image}", :green) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
icon_generator-0.9.0 | lib/icon_generator/touch_builder.rb |
icon_generator-0.8.1 | lib/icon_generator/touch_builder.rb |