Black background being added to transparent PNGs on resize

Hey guys,
I’ve got an issue that I just can’t figure out. I’ve just finished and launched a Kirby site in which I’m resizing pngs with transparent backgrounds, uploaded by the user using the built in resize object. https://getkirby.com/docs/reference/objects/file/resize

This was working fine on our staging server running php 7.1 but when we’ve uploaded the site to the live server (php 7.3) the resized images all have black backgrounds baked in to them. To try and diagnose I’ve changed our staging server to php 7.3 and this has the same affect — black backgrounds start showing up.

Here’s a screenshot of the gd settings on the live server for reference.

Has anyone else noticed this happening? Any help would be much appreciated!

Jack.

The issue was already reported here: Crop Function PNG render Issue. Might have to do with the GD version, see the linked Simpleimage issue. Try switching to ImageMagick if available on your server.

Unfortunately, the TO hasn’t reported if they found a solution.

Thanks @texnixe switching to ImageMagick has solved the issue!

Thanks for reporting back, @jackfowler

Yes, switching to ImageMagic solves the issue, but it would be great that everything works great out of the box.

There is suggested solution you might want to take a look at
https://www.texelate.co.uk/blog/retaining-png-transparency-with-php-gd

Interesting… got the same problem after switching from

php7.2 with gd (Docker) and kirby 3.4
to
php7.4 with gd (Docker) and kirby 3.5.3.1

never had that before… switching the php7.4 Docker from gd to imagick solved it.

I have got the same problem since a few weeks. Locally, with Mamp, I have transparent PNGs, but on my Server, I have black backgrounds in my images. I think it happens since Hosteurope changed their PHP version. From what I see GD and IM are installed on my server.

Hey Marc, hope your are fine.

Have you checked which thumb driver is enabled in your config? And also check with phpinfo() if those libraries are also enabled (in case of GD) or if the path to the convert exe is correct in case of ImageMagick.

Am fine. Thanks :wink:

GD was enabled. I tried to activate IM – which I see is installed on my server – through the config, but Basti said, that the path might be a different one. Trying to re-create all thumbs now anyways. Let’s see … problem right now is, that if I delete my pages folder in media, the images are not created again. Not with IM activated and also not with default settings. Strange.