Module: PSD::Image::Export::PNG
- Included in:
- PSD::Image
- Defined in:
- lib/psd/image_exports/png.rb
Overview
PNG image export. This is the default export format.
Instance Method Summary collapse
-
#save_as_png(file) ⇒ Object
Saves the PNG data to disk.
-
#to_png ⇒ Object
(also: #export)
Load the image pixels into a PNG file and return a reference to the data.
Instance Method Details
#save_as_png(file) ⇒ Object
Saves the PNG data to disk.
26 27 28 |
# File 'lib/psd/image_exports/png.rb', line 26 def save_as_png(file) to_png.save(file, :fast_rgba) end |
#to_png ⇒ Object Also known as: export
Load the image pixels into a PNG file and return a reference to the data.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/psd/image_exports/png.rb', line 7 def to_png return @png if @png PSD.logger.debug "Beginning PNG export" @png = ChunkyPNG::Canvas.new(width.to_i, height.to_i, ChunkyPNG::Color::TRANSPARENT) i = 0 height.times do |y| width.times do |x| @png[x, y] = @pixel_data[i] i += 1 end end @png end |