CrImage::WEBP::Encoder
Encoder handles WebP image encoding.
Provides methods for encoding images to WebP lossless format (VP8L). Handles image conversion, bitstream generation, and RIFF container creation.
Class methods
Encodes image to file path.
Writes the image to a WebP file using lossless VP8L compression.
Parameters:
path: Output file pathimg: Image to encode (must not be nil)options: Optional encoding options
Raises:
ArgumentErrorif image is nil or dimensions are invalidIO::Errorif file write fails
Example:
img = CrImage.read("photo.png")
CrImage::WEBP::Encoder.write("output.webp", img)
Encodes image to IO stream.
Writes the image to an IO stream in WebP lossless format. Performs validation, format conversion, and bitstream generation.
Parameters:
io: Output IO streamimg: Image to encode (must not be nil)options: Optional encoding options
Raises:
ArgumentErrorif image is nil or dimensions invalid (1-16384 pixels)IO::Errorif stream write failsOverflowErrorif arithmetic overflow occurs during encoding
Example:
File.open("output.webp", "wb") do |file|
CrImage::WEBP::Encoder.write(file, img)
end