-
-
Notifications
You must be signed in to change notification settings - Fork 853
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
Use gif to converted have animation webp, but this converted webp image can not import What's app software #2825
Comments
Can you please supply a sample image? It’s critical to allow me to debug anything. |
Please provide an image when you are asked for one. If we find an image that works and it still doesn't work with yours than you are wasting our time. |
@JimBobSquarePants @dlemstra I apologize for my earlier oversight. Since the images we're using have copyright considerations, could you please share your email address? I would like to send the problematic images directly to you. Thank you! |
help @ sixlabors.com |
Thank you very much! I will send the organized data to the specified email address shortly. |
@JimBobSquarePants I've sent the relevant data to your email. Please take a look when you have a moment. I really appreciate all your hard work. Thank you! |
I got your image and had a look. Thanks for sending it through. The good news is that I've tested it against both webpinfo and ezgif splitter and cannot find an issue with it. https://developers.google.com/speed/webp/docs/webpinfo I'm also able to play the WEBP successfully using vwebp, Edge and Firefox on my Windows development machine. So, we know the format of the image is fine. 👍 Let's look deeper at the image though... The provided input GIF file has a background color set at index 63 in the color palette. This color is equivalent to RGBA 255, 255, 255, 255 which is white. ImageSharp will use that information when translating the GIF to a WEBP file to set the background color on the ANIM chunk in the RIFF container. Here's what the specification says about that property.
https://developers.google.com/speed/webp/docs/riff_container#animation It looks to me like the specific decoder which displays the thumbnails is using that background color property to fill outside frames which is different behavior to the decoders on my Windows machine. (ImageSharp optimizes the encoded frames on encode to remove unused areas) Fortunately, it's possible to update that property. using Image gifImage = Image.Load(image);
// Manually copy the properties across.
GifMetadata gMeta = gifImage .Metadata.GetGifMetadata();
WebpMetadata wMeta = gifImage .Metadata.GetWebpMetadata();
wMeta.FileFormat = WebpFileFormatType.Lossless;
wMeta.RepeatCount = gMeta.RepeatCount;
wMeta.BackgroundColor = Color.Transparent;
gifImage.SaveAsWebp(Path.Combine(AppContext.BaseDirectory, "testImageSharp.webp")); Note: The P.S. Your code sample showed you are not disposing of your images. You must do that to prevent memory leaks. |
The webp output is 100% valid according to every test I can apply including official tools from Google themselves. I would use webpinfo to compare blend/disposal properties to see if updating those to match the Magick version changes anything. |
I checked the information on macOS, and the previews in Firefox, Safari, and Chrome all displayed correctly. However, since Magick.NET can convert the file successfully and it passes verification in WhatsApp, I wonder if there might be some differences in the information. I attached the webp file that works after conversion with Magick.NET (named "test.webp") from the help system you provided yesterday; it may be necessary to compare it with the webp generated by ImageSharp to identify any discrepancies. |
That’s what I was asking you to do via webpinfo. |
I followed your suggestion and used webpinfo to analyze the two WEBP files. test.webp is working fine, while testImageSharp.webp has issues when imported into WhatsApp. The webinfo results are as follows.
Conclusion:
|
I would suggest stripping out the XMP data. I would avoid conjecture when describing the differences. Things like offset and background color are perfectly valid. |
After repeated comparisons, I followed your instructions this time and removed the XMP data, but it still didn't work. So, I gradually adjusted the properties to match the webpinfo results of the working image, but it still didn’t help. It wasn't until I added the following statement that it was finally recognized correctly, and I was really excited by the result.😯
After comparison, I found that the images generated by Magick.Net have a Duration of 100 for each ANMF in the webpinfo, while ImageSharp's Duration is set to 0. WhatsApp may use the Duration for its judgment, which could lead to the images generated by ImageSharp being filtered out. I think that ImageSharp should correctly set the Duration property for each ANMF in the WebP metadata when using SaveAsWebp. |
Should ImageSharp handle similar special cases? If possible, I would like to assist in completing this great work. |
NICE DETECTIVE WORK!! 🕵️
ImageSharp is actually doing the correct thing here by performing an exact translation. If you look at the GIF metadata your will see that only the first frame actually has a frame delay set - All the others are zero. (Verified via 3rd party) There's no rule for the minimum frame delay in either specification (nor also APNG) but browsers and other tools tend to use a minimum value for display purposes. I've done some research in the past though for various browsers and here are my findings: Minimum Frame Delay for Animated Formats in Various Browsers
Key Details:
As you can see the minimum display value is inconsistent for GIF files and does not match the default set by Magick.Net. While their approach is a sensible one, I disagree that it is the correct direction for ImageSharp. We should not change metadata without explicit instruction to do so. |
NICE JOB! 👍 I share the same attitude as you, believing that metadata should not be changed arbitrarily. I think this issue can help colleagues in the future address similar situations more elegantly. |
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
3.1.5
Other ImageSharp packages and versions
3.1.5
Environment (Operating system, version and so on)
MacOS
.NET Framework version
.NET8
Description
I am using a GIF image to convert it into an animated WebP, but the resulting WebP image cannot be imported into WhatsApp. It seems to be filtered or rejected by WhatsApp. However, when I use the Magick library to perform the same conversion, the WebP file is successfully imported into WhatsApp.
Here is the code I am using to convert the GIF to WebP:
I would like to know if there is a specific issue with my code or any known differences between the encoding methods that could be causing this problem.
Steps to Reproduce
Images
No response
The text was updated successfully, but these errors were encountered: