hey, thank you very much for this awe... wait for it ...some snippet.
I had the same problem as harmonysteel that the file size of the generated thumbs (in png) were bigger than the original image. I already know about the f-Option but that doesn’t do the trick if you can’t predict the image-format of the original image.
So I just changed some lines in the snippet and I want to share it, if someone had the same problem, or maybe it will be integrated in the next version of phpthumbof.
What I changed was this line:
if (empty($ptOptions['f']))$ptOptions['f'] = 'png';
Into this:
if (empty($ptOptions['f'])){
$ext = strtolower(pathinfo($input, PATHINFO_EXTENSION));
switch($ext){
case 'jpg':
case 'jpeg':
$ptOptions['f'] = 'jpeg';
break;
case 'gif':
$ptOptions['f'] = 'gif';
break;
default:
$ptOptions['f'] = 'png';
break;
}
}
This code take the file extension of the original image and put it as the output format for the thumb-image, but only if the f-Option is not set and it defaults to png for any image-format that isn’t jpg or gif.
Greets from Austria!