-
-
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
greyscale().raw() sets wrong OutputInfo.channels #1425
Comments
Hello, did you see the greyscale docs?
|
Yes, but I'm not sure it's correct. Look at this: const gray = await sharp({create: {width: 100, height: 100, channels: 3, background: {r: 255, g: 255, b: 255}}})
.greyscale()
.raw()
.toBuffer({resolveWithObject: true})
// Comment out this line to get: VipsImage: memory area too small --- should be 30000 bytes, you passed 10000
gray.info.channels = 1
const out = await sharp(gray.data, {raw: {width: gray.info.width, height: gray.info.height, channels: gray.info.channels}})
.raw()
.toBuffer() After the first operation, gray.info.channels = 3. Ok. As per the docs. Problem is, gray.data.length = 10000. And that's just one channel (100x100), or what am I getting wrong? Forcing it to one channel makes the second operaton work. |
Yes, sorry, using Happy to accept and/or help with a PR if you're able to add the fix and a test case. Lines 771 to 774 in de11d36
|
Commit 6f9699f adds a test assertion that would have caught this, plus fixes the bug. This will be in v0.21.1, thanks for reporting. |
v0.21.1 is now available with this fix. |
After doing a grayscale() operation, OutputInfo.channels = 3, when it really should be 1.
Example:
The text was updated successfully, but these errors were encountered: