-
Notifications
You must be signed in to change notification settings - Fork 61
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
PPM or BMP from memory / IO #69
Comments
PPM wouldn't be too hard: vips has its own PPM reader, it would just need adapting to take a memory source. vips8 has vips_magickload_buffer(), it would need wrapping up as a vips7 operation and then adding to ruby-vips. Even better would be to get the new vips8 Ruby binding working, which has all this stuff already :-( This has hit a series of horrible roadblocks. |
Thanks for your quick response! I'm afraid I wouldn't know where or how to start if I were to take this on--anything below the Ruby level is probably out of my league. If there is pattern somewhere I could look at, maybe I could take a crack... |
I've had a quick hack. I'll add patches here as they come in. It looks like the ppm reader/writer is very wedded to reading and writing files, it would need to be reworked quite a bit to be able to read and write memory as well. I'll have a think. I've added |
Probably the best solution would be to fix up the We should take a look at libgsf as well, perhaps that would be better than load-from-stream. |
Wow, thanks! Please let me know if there's anything I can do to help. Speaking of libgsf (though this probably belongs in a separate issue) when trying to install this gem on a fresh Ubuntu 15.04 system, in order to get it to build I had to do:
|
try: irb(main):007:0> png_data = IO.read "k2.png" irb(main):007:0> require 'vips' irb(main):007:0> reader = VIPS::MagickReader.new png_data irb(main):007:0> im = reader.read_buffer irb(main):007:0> im.x_size => 1450 see: #69
It seems to be passing Travis now. You can do stuff like:
It should handle ppm and bmp images too. This is loading via libMagick, which is not quick. You may find going via a file and using the vips ppm loader is quicker. It'll certainly use less memory (of course). I've not pushed this change out as a new version of the gem yet, I'll do a bit more testing (though it now passes the test suite cleanly). You'll also need to build vips from git master, which is annoying. The new |
👍 Thanks! I should have time to test over the weekend or early next week. |
There's a new ruby-vips gem with this feature in. Please open a new issue if there are any problems. |
Wow, great! I was just thinking that I need to get back to this. |
try: irb(main):007:0> png_data = IO.read "k2.png" irb(main):007:0> require 'vips' irb(main):007:0> reader = VIPS::MagickReader.new png_data irb(main):007:0> im = reader.read_buffer irb(main):007:0> im.x_size => 1450 see: libvips/ruby-vips#69
Related to #38 (and following on the solicitation in this comment 😉 ) I have scenario where it would be helpful to do the same with either ppm or bmp images. Would this be feasible?
The text was updated successfully, but these errors were encountered: