-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Accept raw buffer as input #220
Comments
It looks like this should be supported upstream by vips_image_new_from_memory, but may not be detected/implemented because of the differing naming convention from vips_image_new_from_buffer. My local libvips-8.0.2 installed via Homebrew reports |
Yes, it should be quite easy to add this, thanks for the suggestion. We'd need to work out a way for a user to provide the This feature would probably have to assume, at least initially, that the raw data is 8 bits per pixel, with 1x channel for greyscale, 2x channel for greyscale+alpha, 3x channel for sRGB or 4x channel for sRGB+alpha. |
After trying to pass a buffer from the request npm, I can see that this does not currently work, but from the docs, what kind of buffers can be passed to the constructor?
|
@pajtai This issue relates to the addition of support for uncompressed pixel data input. The sharp.format attribute will tell you which compressed formats are available to you (depends on sharp+libvips versions).
If you're still having problems, feel free to create a new issue with more details of the error you're experiencing and, if possible, a code sample. |
Commit e380576 on the |
@lovell : could you share an example of how to use raw inputs? I tried this: var H = 100, W = 100, C = 1, n = H*W*C, data = new Uint8Array(n);
for (var i=0; i<n; i++) {data[i] = 0;}
sharp(new Buffer(data.buffer), { rawWidth: W, rawHeight: H, rawChannels: C})
.toBuffer()
.then(function () {}); but it throws an error ("Input buffer contains unsupported image format") NB: I'm using v0.13.0 (from master branch) |
@nicolaspanel Bonjour, please can you try something like Test/example: https://github.com/lovell/sharp/blob/master/test/unit/io.js#L915-L928 |
It works now 👍 |
v0.13.0 now available, thanks everyone for the original suggestion and help with testing. |
I am currently on 0.28.3 and it looks like raw input is not supported. I try to execute basic case mentioned in the case: https://github.com/lovell/sharp/blob/master/test/unit/io.js#L915-L928 |
@knyga https://sharp.pixelplumbing.com/api-constructor#examples contains an example of using uncompressed pixel data as input. |
For reading pixels from the GPU and then compressing to PNG or JPEG.
The text was updated successfully, but these errors were encountered: