module ChunkyPNG::RMagick
Methods for importing and exporting RMagick image objects.
By default, this module is disabled because of the dependency on RMagick. You need to include this module yourself if you want to use it.
@example
require 'rmagick' require 'chunky_png/rmagick' canvas = ChunkyPNG::Canvas.from_file('filename.png') image = ChunkyPNG::RMagick.export(canvas) # do something with the image using RMagick updated_canvas = ChunkyPNG::RMagick.import(image)
Public Instance Methods
Source
# File lib/chunky_png/rmagick.rb 37 def export(canvas) 38 image = Magick::Image.new(canvas.width, canvas.height) 39 image.import_pixels(0, 0, canvas.width, canvas.height, "RGBA", canvas.pixels.pack("N*")) 40 image 41 end
Source
# File lib/chunky_png/rmagick.rb 29 def import(image) 30 pixels = image.export_pixels_to_str(0, 0, image.columns, image.rows, "RGBA") 31 ChunkyPNG::Canvas.from_rgba_stream(image.columns, image.rows, pixels) 32 end