Sha256: 56eb00576da75bd6f7750e7dd84c1c8a249de81ab09882e37634fa472266af81
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# # Strategy for build a scaled image # class SepiaScaledImageStrategy attr_reader :name, :width, :height, :quality def initialize( name, width, height, quality ) @name = name @width = width @height = height @quality = quality end # # build a scaled image and store it in outpath # # inpath source image file # outpath destination image file # def build( inpath, outpath ) # TODO: ritornare un risultato per es. 1 = skipped 2 = copiato 3 = scalata immagine result_msg = "" img = Magick::ImageList.new(inpath) if @width > img.columns and @height > img.rows result_msg = "(c) " # FileUtils.cp( inpath, outpath ) # rimuovere i metadata else result_msg = "(#{@quality}%) " img.resize_to_fit!(@width, @height) end img = img.sepiatone img.profile!('*', nil) img.write(outpath) {|i| i.quality = quality } result_msg end def write_xml( xml_iss ) xml_is = xml_iss.add_element( "image_strategy") xml_is.attributes["name"] = self.class.to_s xml_par = xml_is.add_element("par") xml_par.attributes["width"] = @width xml_par.attributes["height"] = @height xml_par.attributes["quality"] = @quality end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gf-ralbum-0.0.5 | lib/ralbum/image_strategies/sepia_scaled_image_strategy.rb |