# Thumbnail creation for PNG Files fails

**URL:** <https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900>\
**Category:** Questions\
**Tags:** v2\
**Created:** [December 28, 2018, 9:49pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900 "2018-12-28T21:49:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 28, 2018, 9:49pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/1 "2018-12-28T21:49:41Z")

</div>

Hello,

i have another problem with my thumbnail creation. While displaying full size PNG Files works without a problem, thumbnail creation of them always fail.

I’m clueless where to look. Command Line ‘convert’ works without a problem. I’m using the ‘im’ thumbs driver.

```
c::set('thumbs.driver', 'im');	
c::set('thumbs.bin', '/usr/local/bin/convert');

```

Any idea where I should dive deeper?

Regards Alex

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 28, 2018, 9:51pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/2 "2018-12-28T21:51:49Z")

</div>

Do jpgs-thumbnails get created with the im driver?

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 28, 2018, 9:52pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/3 "2018-12-28T21:52:26Z")

</div>

Yes, they work without problems.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 28, 2018, 9:58pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/4 "2018-12-28T21:58:26Z")

</div>

What is your environment?

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 28, 2018, 10:03pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/5 "2018-12-28T22:03:17Z")

</div>

Production environment:  
Linux (Arch Linux), PHP 7.3, nginx, ImageMagick 7.0.8-21, libPNG 1.6.35

Same problem on my local dev environment:  
OSX, PHP 7.3, nginx, ImageMagick, ImageMagick 7.0.8-21, libPNG 1.6.35

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [December 28, 2018, 10:06pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/6 "2018-12-28T22:06:32Z")

</div>

How much ram have you given PHP in the ini settings? PNGs usually take a little more horsepower to manipulate than JPEGS. Does this happen with all PNG files or just large ones in pixel dimensions and file size. have you tried a small one?

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 28, 2018, 10:09pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/7 "2018-12-28T22:09:40Z")

</div>

The php memory\_limit is set to 512M. The thumbnail creation for really small pngs also fails.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 28, 2018, 10:11pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/8 "2018-12-28T22:11:06Z")

</div>

What about the max\_execution\_time? But if it even fails for small pngs…, hm. Note that if the png is too small, thumbnails are not created, so the physical size should actually be bigger than the thumbnails size.

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 28, 2018, 10:12pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/9 "2018-12-28T22:12:56Z")

</div>

max\_execution\_time 30, but setting it to 180 does not solve the problem.

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [December 28, 2018, 10:14pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/10 "2018-12-28T22:14:41Z")

</div>

Does it also fail to make thumbnail if you use the imagemagick from the command line outside of Kirby? Its interesting that you have identical versions on both live and local and both fail. Im wondering if its a bug with that exact build of imagemagick.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 28, 2018, 10:16pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/11 "2018-12-28T22:16:21Z")

</div>

@rcvd already said that is works from the command line.

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 28, 2018, 10:17pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/12 "2018-12-28T22:17:26Z")

</div>

Maybe I’m not using the same parameter as Kirby? Just tried a simple convert…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 28, 2018, 10:20pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/13 "2018-12-28T22:20:47Z")

</div>

This is what the driver does, depending on settings:

```auto
/**
 * ImageMagick Driver
 */
thumb::$drivers['im'] = function($thumb) {

  $command = array();

  $command[] = isset($thumb->options['bin']) ? $thumb->options['bin'] : 'convert';
  $command[] = '"' . $thumb->source->root() . '"';
  $command[] = '-strip';

  if($thumb->options['interlace']) {
    $command[] = '-interlace line';
  }

  if($thumb->source->extension() === 'gif') {
    $command[] = '-coalesce';
  }

  if($thumb->options['grayscale']) {
    $command[] = '-colorspace gray';
  }

  if($thumb->options['autoOrient']) {
    $command[] = '-auto-orient';
  }

  $command[] = '-resize';

  if($thumb->options['crop']) {
    if(empty($thumb->options['height'])) {
      $thumb->options['height'] = $thumb->options['width'];
    }
    $command[] = $thumb->options['width'] . 'x' . $thumb->options['height'] . '^';
    $command[] = '-gravity Center -crop ' . $thumb->options['width'] . 'x' . $thumb->options['height'] . '+0+0';
  } else {
    $dimensions = clone $thumb->source->dimensions();
    $dimensions->fitWidthAndHeight($thumb->options['width'], $thumb->options['height'], $thumb->options['upscale']);
    $command[] = $dimensions->width() . 'x' . $dimensions->height() . '!';
  }

  $command[] = '-quality ' . $thumb->options['quality'];

  if($thumb->options['blur']) {
    $command[] = '-blur 0x' . $thumb->options['blurpx'];
  }

  $command[] = '-limit thread 1';
  $command[] = '"' . $thumb->destination->root . '"';

  exec(implode(' ', $command));

};

```

So if jpgs work, the driver seems to work ok, the php.ini settings seems to be ok as well.

I haven’t tested anything with PHP 7.3 yet…

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 28, 2018, 10:24pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/14 "2018-12-28T22:24:34Z")

</div>

```
convert input.png -strip -auto-orient -limit thread 1 -quality 90 -resize 400x400 -interlace line resized.png

```

This works without problems…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 28, 2018, 10:25pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/15 "2018-12-28T22:25:57Z")

</div>

Can you see anything in the error logs?

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 28, 2018, 10:46pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/16 "2018-12-28T22:46:50Z")

</div>

I can’t see anything…but I’m not sure that my php logging is configured right…

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [December 28, 2018, 11:06pm UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/17 "2018-12-28T23:06:55Z")

</div>

> [@rcvd](#):
>
> libPNG 1.6.35

I just noticed that libPNG is now at version 1.6.36 try updating it locally and see if the issue persists.

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 29, 2018, 8:43am UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/18 "2018-12-29T08:43:25Z")

</div>

The problem seems to be caused by a configured png optimizer (pngquant / triggered by imagekit), if I remove this png starts working again. Sorry for the confusion…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 29, 2018, 11:07am UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/19 "2018-12-29T11:07:33Z")

</div>

Ah, didn‘t know you are using imagekit.

---

<div class="post-metadata">

**Author:** ![rcvd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rcvd/32/5905_2.png) [@rcvd](https://forum.getkirby.com/u/rcvd)\
**Post date:** [December 29, 2018, 11:27am UTC](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900/20 "2018-12-29T11:27:04Z")

</div>

My fault…had to state this first.

[Next page](https://forum.getkirby.com/t/thumbnail-creation-for-png-files-fails/11900.md?page=2)
