# Thumb images larger than original

**URL:** <https://forum.getkirby.com/t/thumb-images-larger-than-original/4640>\
**Category:** Questions\
**Tags:** v2\
**Created:** [July 7, 2016, 6:14pm UTC](https://forum.getkirby.com/t/thumb-images-larger-than-original/4640 "2016-07-07T18:14:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [July 7, 2016, 6:14pm UTC](https://forum.getkirby.com/t/thumb-images-larger-than-original/4640/1 "2016-07-07T18:14:18Z")

</div>

Hello,  
I’m testing the thumb functionnality at the moment and I’m quite surprised by the results.  
My test is simple:

- I have an original image that is optimized with tinypng.
- I then use the thumb function to create different sizes of the image for a responsive image with srcset
- I compare the size of the returned images with the original.

Here’s one example:  
url: [http://hiweb.fr/whitespace/portfolio/blue-fruity](http://hiweb.fr/whitespace/portfolio/blue-fruity)  
The first image on the page is 90 496 bites before using thumb. Dimensions 850_567  
The same size image but using thumb is 97 274 bites. Same dimensions  
A smaller image using thumb is 100 499 bites. Dimensions 768_512

I’m using the default image driver as image magick is not available on my server. Is there a configuration I should know of to optimize compression without affecting quality?

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [July 7, 2016, 6:29pm UTC](https://forum.getkirby.com/t/thumb-images-larger-than-original/4640/2 "2016-07-07T18:29:09Z")

</div>

What you see is correct. GD (and as far as I know IM as well) don’t optimize the images. It only really makes sense to generate thumbs if the thumbs are a lot smaller than the original image. Otherwise, manually optimized images are better.

What you can do though is to run the thumbs through tinypng manually after they are generated. Maybe there’s also an easier or automatic way.

---

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [July 7, 2016, 6:31pm UTC](https://forum.getkirby.com/t/thumb-images-larger-than-original/4640/3 "2016-07-07T18:31:17Z")

</div>

Thanks for your answer @lukasbestle

I think what I can do is wait for @fabianmichael’s imagekit to tackle this issue 🙂

I’m using the thumbs here because this is part of a theme and users won’t necessarily have optimized their images before uploading them.

---

<div class="post-metadata">

**Author:** ![fabianmichael](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/fabianmichael/32/13901_2.png) [@fabianmichael](https://forum.getkirby.com/u/fabianmichael)\
**Post date:** [July 7, 2016, 7:02pm UTC](https://forum.getkirby.com/t/thumb-images-larger-than-original/4640/4 "2016-07-07T19:02:25Z")

</div>

Hey @Thiousi, thanks for the trust in my plugin. However, the current version does not support automatic optimization, altough I already considered this for a future release …

For now, you could extend Kirby’s GD driver which makes use of the TinyPNG API, they also offer a [PHP library](https://tinypng.com/developers/reference/php) for using their service. Or – if it is available on your server – you could use a command-line tool like [OptiPNG](http://optipng.sourceforge.net/).

Put the following lines into a custom plugin file:

```php
<?php

$originalDriver = thumb::$drivers['gd'];

thumb::$drivers['gd'] = function($thumb) use ($originalDriver) {
  
  // Execute the original driver and create the resized image
  $originalDriver($thumb);
  
  // Abort, if there was an error
  if(!is_null($thumb->error()) return;

  // Put your your image optimization code below this comment.
  // You can get the thumb file’s path from: $thumb->destination->root
};

```

Because optimization also needs some time to finish, the thumbnail creation & optimization process will take longer much than normal. So this would indeed be a perfect use-case for 🎉 … [ImageKit](https://github.com/fabianmichael/kirby-imagekit). 😉

Hope, I could help you with this.

---

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [July 7, 2016, 7:30pm UTC](https://forum.getkirby.com/t/thumb-images-larger-than-original/4640/5 "2016-07-07T19:30:07Z")

</div>

I’m definitely looking forward to the extensions of imagekit you’ve mentioned 😉

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:57pm UTC](https://forum.getkirby.com/t/thumb-images-larger-than-original/4640/6 "2025-02-06T16:57:37Z")

</div>


