Skip to content
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

embed error #204

Closed
mikemliu opened this issue Apr 28, 2015 · 7 comments
Closed

embed error #204

mikemliu opened this issue Apr 28, 2015 · 7 comments
Labels
Milestone

Comments

@mikemliu
Copy link

Getting an error embedding png with transparency on the default black background (inside larger background canvas)

start with a 50x50 png with alpha channel:

sharp(in)
.resize(50, 256)
.embed()
.pipe(out)

i get the following:

Error: linear: vector must have 1 or 4 elements

The following DO work:

  • embedding a png with no transparency
  • embedding on a background that matches the source aspect ratio
@mikemliu
Copy link
Author

Flatten seems to resolve the issue:

sharp(in)
.resize(50, 256)
.flatten()
.embed()
.pipe(out)

@lovell
Copy link
Owner

lovell commented Apr 29, 2015

Looks like a bug, thanks for reporting this. I'll try to add a test case to confirm this later today.

Were you hoping to preserve transparency in the output image?

@lovell
Copy link
Owner

lovell commented Apr 29, 2015

I've reproduced this @mikemliu. It occurs when embedding an image with an alpha channel onto any background colour that does not have a transparency, which includes the default.

I've added a new test case to expose the failure and the fix in commit 33782d3.

Are you able to retest via npm install lovell/sharp?

@mikemliu
Copy link
Author

I realized the same when I actually put in my desired transparent background. Thanks!

@lovell
Copy link
Owner

lovell commented Apr 30, 2015

@mikemliu Were you able to confirm this fix solved the problem? If so I'll publish a point release with it to npm.

@mikemliu
Copy link
Author

confirmed. thanks!

@lovell lovell closed this as completed May 1, 2015
@lovell lovell added this to the v0.10.1 milestone May 1, 2015
@lovell
Copy link
Owner

lovell commented Jun 1, 2015

This is fixed in v0.10.1, now available via npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants