ImageSharp icon indicating copy to clipboard operation
ImageSharp copied to clipboard

Gif Problem for facebook

Open GVX111 opened this issue 9 years ago • 12 comments

Hello guys. I have problem on facebook. When i sharing gif image which is resized in ImageSharp image doesnt loop and stopping.

example: https://developers.facebook.com/tools/debug/sharing/?q=https%3A%2F%2Fcloud.githubusercontent.com%2Fassets%2F1840003%2F21365920%2F1c479680-c6bd-11e6-80e7-ad4016976a7f.gif

GVX111 avatar Jan 17 '17 16:01 GVX111

Odd... I'll double check the loop property logic later. Is it just on Facebook, if so could they be altering the displayed image?

JimBobSquarePants avatar Jan 17 '17 19:01 JimBobSquarePants

can you give me some info where can i find this loop logic? I will fix it. Is it problem of GifEncoding? this problem has only Facebook. I must publish project tomorrow and can't publish because of this problem. Please help me

GVX111 avatar Jan 17 '17 20:01 GVX111

I am guessing that Facebook is changing the image. When you view the image it looks okay: https://cloud.githubusercontent.com/assets/1840003%2F21365920%2F1c479680-c6bd-11e6-80e7-ad4016976a7f.gif. I don't have Facebook so I cannot check what is going on there.

dlemstra avatar Jan 17 '17 20:01 dlemstra

you can check without facebook account with this tool: https://developers.facebook.com/tools/debug/sharing/ I tested with original .gif and it's working on facebook.

GVX111 avatar Jan 17 '17 20:01 GVX111

Facebook is telling me to login but I don't have an account so I can't check that page. Is this your output image: https://cloud.githubusercontent.com/assets/1840003%2F21365920%2F1c479680-c6bd-11e6-80e7-ad4016976a7f.gif? It looks okay to me.

dlemstra avatar Jan 17 '17 20:01 dlemstra

I will explain problem: I'm adding watermark on the gif file. after i'm sharing this file on facebook. Gif starting without problem but doesn't looping,

GVX111 avatar Jan 17 '17 20:01 GVX111

Your problem is clear but I have no idea how you end up with the output file. First you tell us that you resize the image an now you suddenly add a watermark. Can you share a small code sample that we can use to reproduce the issue?

dlemstra avatar Jan 17 '17 20:01 dlemstra

Also i tried save gif without add watermark but same problem Sure:

using (FileStream watermarkstream = System.IO.File.OpenRead(Path.Combine(_env.ContentRootPath, "Resources", "watermark.png")))
using (var fileStream = new FileStream(Path.Combine(_env.WebRootPath, "9b89a6cb-69ac-444f-b458-8a66c0c899fe.gif"), FileMode.Open, FileAccess.ReadWrite))
using (FileStream output = System.IO.File.OpenWrite(Path.Combine(_env.WebRootPath, "New", "9b89a6cb-69ac-444f-b458-8a66c0c899fe.gif")))
{
  ImageSharp.Image watermark = new ImageSharp.Image(watermarkstream);
  ImageSharp.Image img = new ImageSharp.Image(fileStream);

  int waterMarkWidth = img.Width / 6;
  var waterMarkHeight = waterMarkWidth * watermark.Height / watermark.Width;
  var waterMarkPosition = ImageHelper.WatermarkPosition(img.Width, img.Height, waterMarkWidth, waterMarkHeight);
  img.DrawImage(watermark, 70, new Size(waterMarkWidth, waterMarkHeight), waterMarkPosition);
  img.Save(output, new GifEncoder() { Quantizer = new PaletteQuantizer<Color>() });
}

GVX111 avatar Jan 17 '17 21:01 GVX111

Thanks for the code sample.

If the problem only exists on Facebook then I suspect Facebook is changing the file. I would do a compare between the file saved and the file rendered. I suspect they purposely alter the loop count to reduce animation in Facebook posts.

JimBobSquarePants avatar Jan 17 '17 22:01 JimBobSquarePants

Thank you I think so facebook changing the file, but why original .gif file working?

GVX111 avatar Jan 17 '17 22:01 GVX111

but why original .gif file working

I'm sorry, I don't understand.

JimBobSquarePants avatar Jan 17 '17 22:01 JimBobSquarePants

Closing as this is not an issue with ImageSharp.

Facebook seems to be manipulating the file before rendering.

tocsoft avatar Jan 20 '17 12:01 tocsoft