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

Add ability to trim only transparent pixels #2843

Closed
chescos opened this issue Aug 15, 2021 · 2 comments
Closed

Add ability to trim only transparent pixels #2843

chescos opened this issue Aug 15, 2021 · 2 comments

Comments

@chescos
Copy link

chescos commented Aug 15, 2021

What are you trying to achieve?

I'm looking to "crop an image to its content". That is, remove/trim/crop all possible transparent pixels at the edges of the image.

In some cases, this is possible with the trim() function. But there are cases where trim() behaves weird (see #2842) and then there are cases where the top left pixel is not transparent, but the bottom or right side of the image have transparent parts that can be trimmed.

Have you searched for similar feature requests?

Yes

What would you expect the API to look like?

I'm not sure, maybe trimTransparent().

What alternatives have you considered?

I've searched around Google and Github to find a solution for this, even with other JS libraries, but I haven't found anything that can reliably achieve this.

Is there a sample image that helps explain?

Consider this image:

in

I'd like to trim all transparent pixels from the edges, resulting in this image:

out

@lovell
Copy link
Owner

lovell commented Aug 15, 2021

Please see #2166

@lovell lovell closed this as completed Sep 5, 2021
@danielo515
Copy link

Sorry for comment in Ann old issue, but how is this achieved?

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

No branches or pull requests

3 participants