Closed Sija closed 8 months ago
AVIF is supported by libvips starting from version v8.8.0, so if you are using version above that, you should be able to invoke operations to work on avif format.
For simple image conversion, below snippet works.
im = Vips::Image.new_from_file("input.jpg")
im.write_to_file("output.avif")
Great, thanks for the clarification! My use case though requires getting the buffer instead of writing to a file, how can I do this?
My use case though requires getting the buffer instead of writing to a file, how can I do this?
You can use Vips::Target
in this case.
im = Vips::Image.new_from_file("test.jpg")
target = Vips::Target.new_to_memory
im.write_to_target(target, "%.avif")
bytes = target.blob # bytes is Slice containing all of the image data
.....
Works like a charm, thanks! ❤️
SSIA