I’m using the thumbsever route made by @texnixe now I’m wondering it it is possible to detect if the input file is a png or a jpg so I can create the thumb in the right format. Especially if the source file has transparency this would be useful.
[
'pattern' => 'thumbserver/(:any)',
'action' => function ($fileUuid) {
$file = site()->index()->files()->findBy('uuid', 'file://' . $fileUuid);
if ($file) {
$width = get('width') ?? 200;
$height = get('height') ?? 200;
$format = get('format') ?? 'jpg';
$quality = get('quality') ?? 70;
$crop = get('crop') ?? false;
return Response::file($file->thumb([
'width' => $width,
'height' => $height,
'crop' => $crop,
'format' => $format,
]
)->url());
}
return null;
},
]