ruby-libgd

GD::Image#to_png

Encodes the image as PNG and returns the binary string.

Signature

to_png -> String

Example

data = img.to_png
File.binwrite("out.png", data)