-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set file type #63
Comments
Hmmm, I'd probably say it's out of scope for this plugin (we're just about resizing, not further manipulation), but anything is possible. There's lots of complexities to converting images between JPG/PNG/GIF/SVG, and not to mention throwing in newer formats like WEBP/AVIF and even more older/obscure ones like TIFF/BMP. There's lots to consider that's possibly more in the realm of something like ImageOptimize |
Thanks, I understand. I thought it would make sense because we can also set the quality and I was only thing about webp. |
I agree this would be very useful. It definitely would be expanding the scope of this plugin, but it would fit into the realm of "optimize assets on upload", which is the deeper purpose of this plugin. Implementation-wise, I wonder if it may be as simple as hooking into the native transform system - basically define an image transform, and simply apply it on image upload. |
Something like this as an outline? $format = ImageResizer::$plugin->getSettings()->format;
if ($format) {
$transform = new ImageTransform(['format' => $format]);
$url = $asset->getUrl($transform);
# somehow get asset path from $url above
Craft::$app->assets->replaceAssetFile($asset, <asset-path>, $newfilename);
} But I'm sure in reality that's probably only 10% of what you'd need to add... |
I'll say that at the moment, "optimize assets on upload" is even out of scope for the plugin (which is why we'd pick ImageOptimize for that), but at some point, one day - we do want to include that functionality to Image Resizer. It'd be great to have a free option to optimize images, and even change the filetype. All too often, out clients upload PNGs instead of JPEGs for images which can afford to be lossy. That wreaks a bit of havoc on image sizes. We'll keep it all in mind! |
Maybe it is already possible and I don't find it. But it would be great to have a setting to change the file type after resizing an image. For example to webp.
The text was updated successfully, but these errors were encountered: