-
Notifications
You must be signed in to change notification settings - Fork 60
Formats not supported by VipsForeignSaveRawBuffer #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @anitagraham, They should mostly work. Perhaps you are missing some libraries? For avif, heic, heif save to buffer you need
In 8.11, GIF save is done via BMP is also via WEBP should work, perhaps you are missing the webp libraries? JP2K should also work. Again, you need to configure with OpenJPEG. I would check the summary table at the end of libvips configure. It sounds like a lot of things are not there. |
I meant to say, libvips from 8.10 has a new low-level IO system based on The The docs have some info on these classes in Ruby: |
I made you a small test prog: #!/usr/bin/ruby
require 'vips'
x = Vips::Image.new_from_file ARGV[0]
%w(dz hdr jpc jpt jp2 j2c j2k webp).each do |format|
begin
buf = x.write_to_buffer ".#{format}"
puts "#{format}: written #{buf.length} bytes"
rescue Vips::Error
puts "#{format}: buffer write not supported"
end
end
# imagemagick-based savers need to be told the for format to write twice :(
%w(bmp gif).each do |format|
begin
buf = x.write_to_buffer ".#{format}", format: format
puts "#{format}: written #{buf.length} bytes"
rescue Vips::Error
puts "#{format}: buffer write not supported"
end
end
# libheif buffer savers need to be told the format too
buf = x.write_to_buffer ".heif", compression: "hevc"
puts "heic: written #{buf.length} bytes"
buf = x.write_to_buffer ".heif", compression: "av1"
puts "avif: written #{buf.length} bytes" I see:
The extra parameter for imagemagick is very unfortunate. That's with 8.11, 8.12 will fix the GIF one at least. We ought to extend the target API a bit and fix all these stupid special cases. |
Yes - running the test script from my home folder gets the expected results. I'll have to see what's happening in the test environment. Thanks. |
Thanks John. Tests all passing now. I appreciate the effort you put in - and have been putting in for a long time. |
Currently, buffer and target savers are not told the format they should write. This is usually OK (the JPEG saver already knows it should write JPEG), but some savers can write several formats, and these currently need an extra parameter. For example: ```ruby buf = x.write_to_buffer ".bmp", format: "bmp" ``` The first ".bmp" gets libvips to pick magicksave, the second `format:` param is necessary to tell magicksave to write BMP. This patch makes `vips_image_write_to_buffer` and `vips_image_write_to_target` add an extra image metadata item called `format_string` which contains the string used to pick the write format. Savers can use this extra field (if present) to pick a default save format. In this case, the magick saver will extract the "bmp". See: libvips/ruby-vips#319
8.12 will have a fixed-up buffer save system. With this code: %w(bmp gif heif avif ppm pfm pgm pbm).each do |format|
buf = x.write_to_buffer ".#{format}"
puts "#{format}: written #{buf.length} bytes"
end I now see:
Thanks for suggesting this! |
I found - running the test suite for
dragonfly-libvips
- that there are several image formats which are not supported byForeignSaveBuffer
.The formats are
avif, bmp, dz, gif, hdr, heic, heif, jpc, jpt, jp2, j2c, j2k and webp
.dragonfly_libvips
typically processes an image (resize, crop, encode), then returns it to the caller after writing the new image to a buffer so:I'm not familiar with all the image formats listed, but I can imagine wanting to handle
webp
orheic
.At the moment I have added them to a list of unsupported formats but I wonder if any, all or some should be added to
foreign
.thanks
The text was updated successfully, but these errors were encountered: