veda-consulting-company / uk.co.vedaconsulting.mosaico

Other
39 stars 75 forks source link

Mosaico fails on animated .GIFs #285

Closed MegaphoneJon closed 2 years ago

MegaphoneJon commented 5 years ago

Mosaico can't handle uploaded animated GIFs because it fails on resize.

I wrote a patch but I'm using 2.0beta4 in production, not master - and this function has been refactored into another file.

For others looking for a solution, my commit is here: https://github.com/MegaphoneJon/uk.co.vedaconsulting.mosaico/commit/0b9e25cbf86416f3d3ac6b712c17d03f4c33170c. I'm going to let my users test this in production and if it looks good I'll rewrite it against master.

deepak-srivastava commented 5 years ago

Hi @MegaphoneJon, this is interesting and must have :+1:

I tried applying your patch on latest repo. I do see resized gif images being rendered but not animate. Do you expect same results or you expect them to animate as well?

MegaphoneJon commented 5 years ago

They animate for me - though I think I'm losing the animation timing of the original. I think I'll need to add getImageDelay and setImageDelay to preserve original timing.

During my testing I was accidentally creating non-animated GIFs - one trick I used was to run identify on the command line to see how many frames were in the converted GIF so I didn't need to view the GIF to test.

deepak-srivastava commented 5 years ago

I've created a new branch (animated-gifs) with your changes applied - https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/compare/animated-gifs?expand=1 Seems like i might have missed something as i don't see the animation.

Feel free to PR experimental code to it, so we can feedback as well.

Thanks.

MegaphoneJon commented 5 years ago

@deepak-srivastava While generally I support the move to Intervention/image, it doesn't support animated GIFs: https://github.com/Intervention/image/issues/176

I asked on that thread where the development branch is. While I'd rather not build both a gd-based and imagick-based solution to this, I would be willing to patch one in if I can steal it from the dev branch...

francescbassas commented 2 years ago

@mattwire this issue was closed but has not been resolved, right? It's still not possible to add animated gifs, is it? @MegaphoneJon https://github.com/MegaphoneJon/uk.co.vedaconsulting.mosaico/commit/0b9e25cbf86416f3d3ac6b712c17d03f4c33170c are you still using this patch? It works?

MegaphoneJon commented 2 years ago

@francescbassas Originally, this extension had different code written for folks with ImageMagick installed and folks with GD installed.

At some point, it was replaced with Intervention Image, an abstraction layer that supports both ImageMagick and GD. Unfortunately, Intervention Image doesn't support animated GIFs.

I haven't used my patch in a long time, but to test it, you need to go to Administer » CiviMail » Mosaico Settings and from Mosaico graphics driver select (Deprecated) Direct ImageMagick API. It probably still works because the deprecated code is unlikely to have changed.

francescbassas commented 2 years ago

StackExchange related discussion here https://civicrm.stackexchange.com/questions/34427

MegaphoneJon commented 1 year ago

@francescbassas there's a dirty trick to use if you absolutely must have an animated GIF. Create the mailing as you normally would. After saving, find the static GIF in your file system and upload a copy via SFTP or similar. By uploading directly, you bypass intervention/image.

francescbassas commented 8 months ago

Upgrade to intervention/image 3.0 #625