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: prevent image uploader converting every image to jpeg #1262
Conversation
@ikadix is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
@emrysal is there any downside of saving as mimeType? in terms of cropping & filesize, etc. if there is no downside, this PR LGTM |
When reviewing #1267 I realised that there's a consideration for i18n of the error message given for unsupported MIME Type. |
Maybe my thought is wrong here, but rather than using the input image file format, isn't it an simpler approach to use .png instead of jpg for saving images? That would likely result in more support for more file types and would also resolve the transparency issues; without adding any logic? |
@emrysal You are 100% correct with that thought, removed mime type changes, only PNG matters for transparency support and this actually works with webm now 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Awesome!
What does this PR do?
Currently all images are converted to jpeg after going through the cropping process. This removes the ability to upload images that have transparent backgrounds, like company logos. This PR reads the mime type from the image source and attempts to save it as that.
This has the issue of webp failing and also I imagine AVIF, basically anything that JIMP doesn't support.
The error returned by JIMP seems reasonable enough to users IMO, but could add some warning label regarding the images supported?
JIMP lists support for the following formats, but also SVG seems to work just fine.
This is the error message returned from JIMP in the UI.
Currently an image with a transparent background would get a black background like this
This PR changes this to preserve transparency
The view before uploading a new image has the background replaced and a background is just applied to the image, this works a little nicer than a border around it at the moment I believe.
Type of change
How should this be tested?
I have manually tested, each of the image types that JIMP supports, as well as webp to confirm the error message.
I can look to add automated tests for this if you would like, I might need some assistance with that however.
Checklist: