I use the below code to resize JPG files to 200x240 pixels. The attached example file has a size of 900x600 pixels and is only 84 kb. However when I save the resized file using ImageSharp, the produced image is 435 kb! Why is the smaller image has a bigger file size?
I noticed that the bit depth of the original image is 24 bits but ImageSharp stores it with 32 bits. How can I reduce this?
Resized image:
var thumbImage = image.Clone(x => x.GetCurrentSize());
if (thumbImage.Width > 200)
{
thumbImage.Mutate(m =>
{
m.Resize(new ResizeOptions
{
Mode = ResizeMode.Min,
Size = new Size(200, 0)
});
});
It took me some time to figure out how to do it for a bit-depth of 24, i wish they extended the Save method with more obvious parameters, anyway here is the code.
if you save as jpeg(like the original image you have here) you will get way smaller image size, and bit-depth will stay the same as the source.