Let's say i was looking for a way to convert images into a format, that is perfectly suited for webhosting.
That means, decent enough quality and low file size.
The classics are .jpg and .png, which are also the most supported.
But...there is another good one, that is getting better and better support, while providing smaller file sizes.
And that is WebP (there is also AVIF, but its less supported).
From what i know, it was developed by Google and is a good open format.
Now, there comes just one little problem...converting whatever you have into .webp is a pain.
So, i have been looking for solutions, and i will share some of them with you.
Using ImageMagick
Probably easiest to use, but requires the ImageMagick software.
Can also pre and post process images and supports lots of different image formats.
Truly the swiss army knife for image processing over the CLI.
Here is a simple Linux script (using the installed imagemagick package on Linux Mint) that
converts whatever image file into a separate .webp image file.
#!/usr/bin/env bash
image_filepath="${1}"
convert "${image_filepath}" -quality 100 "${image_filepath%.*}.webp"
Keep you eye out to the -quality parameter.
This one determines if you want lossless or lossy compression.
If your image is complex (lets say, landscape with lots of objects),
i recommend using lossy compression and playing with the -quality parameter abit.
Servers as a alternative to .jpg.
For logos or simpler images, that cannot hide compression artifacts in complex geometry,
just set the -quality parameter at 100, to get lossless compression.
Servers as a alternative to .png.