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

fix png transparent bug #3474

Closed
wants to merge 1 commit into from
Closed

fix png transparent bug #3474

wants to merge 1 commit into from

Conversation

ariaieboy
Copy link
Contributor

There is an unnecessary format change when doing conversation that makes some weird bug when we use the GD driver.
This one line of code made me read the whole system of the image, image-optimizer, and laravel media library package 😊

the image input:
image

the result after converting to webp format with a white background before this PR:
image

and after this PR:
image

@freekmurze
Copy link
Member

By default, the media library will make jpg conversions. If you don't want that behaviour, tack on shouldKeepOriginalImageFormat() to your conversion and the result will be a png (when your input is a png)

@freekmurze freekmurze closed this Dec 22, 2023
@ariaieboy
Copy link
Contributor Author

By default, the media library will make jpg conversions. If you don't want that behaviour, tack on shouldKeepOriginalImageFormat() to your conversion and the result will be a png (when your input is a png)

The keepOriginalImageFormat method is not fixing my problem.
The problem is that when you use the imagick driver the format change won't take place until you write the image.
But in the GD driver when you call the format method the image actually changes to that format.
Since the JPG does not support transparent background. it's either gonna generate a black background or in my case this weird background.

@freekmurze freekmurze reopened this Dec 22, 2023
@ariaieboy ariaieboy marked this pull request as draft December 22, 2023 09:01
@ariaieboy
Copy link
Contributor Author

I think instead of changing this here we should change the GD driver format method.
It must save the format and apply it when we call the save method.

@freekmurze
Copy link
Member

I think instead of changing this here we should change the GD driver format method.
It must save the format and apply it when we call the save method.

Yeah, that would be better I think. You're up for making that PR?

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

Successfully merging this pull request may close these issues.

2 participants