Gif's not playing

Hey - I want to show gifs with Kirby, but they are not playing. It just shows the first frame.

This is my code:

<?php
$images = $subpage->gallery()->toFiles();
foreach($images as $image): ?>
  <img src="<?= $image->crop(300, 300)->url() ?>" alt="" >
 </a>
<?php endforeach ?>

How can I play gif’s with Kirby?

Did you try to not use “crop”?

For my understanding this produces ONE picture, not some pictures in a gif-file.

You can use a CSS-file, if you need a lower size in the rendered page.

They are playing without the resize attribute. But I have several other pictures that need to be resized.

You could check the file mime-type and only resize non-gif images.

1 Like

Yes, that’d be one solution.

I have another question regarding resizing.
In some images, the color changes to either really saturated or desaturated. But thats only in the resized images the case. Is there any solution?


Resized (left) Original (right)

When you resize them, the original color information is stripped.

To prevent this, you can use the ImageMagick library in conjunction with a custom driver that does not strip color profiles.

Alright. I’ve changed the engine to imageMagick, but it doesn’t do anything.

Like this
config.php

return [
  'thumbs' => [
    'driver' => 'im'
  ]
];

Do I have to install something?

Edit: It changes the img’s url to something like 200x-q50.jpg, but the image is still in the original size.

Well, if you change to ImageMagick without having it installed, then nothing will happen to the images. So make sure that IM is available. You might have to provide the path to the convert binary in config as well.

Secondly, just changing to IM won’t help either, because the default IM driver strips the image information. That’s why I said you need a custom driver.

I need to use the gd libary for thumb generation, but for animated gifs I want use Image Magick. So I’m landed here in this thread. I’m wondering where and how the check could be done. Do I need a custom Darkroom Renderer?

Thank You

Why do you want to use gd for non-gif files?

We have very large photos and im’s limit seems to be to small for our needs.
I didnt find a way to change this limitations.
The images have to be available in big resolutions, so we cant restrict the upload sizes.
On the other hand we dont want to loose the gif-animations.

Our galleries are using srcset and sizes

What limitations are you talking about? To my understanding, at least in the past, those limitations were rather with GD…

In my case thumbs of jpgs with original size 6000x4000 are not rendered by “im”. At now I’m still developing on the build-in-php server. The production server will be a rented host. Maybe I have to test it online first.

If you really need to set the driver conditionally, the right place would probably be a custom thumb component.

Check out the original component where the driver is set: