0

I'm developing software using .Net Framework and .Net 6.
I would like to reduce the weight of images (Jpeg or PNG) of about 2MB in the software I am developing, with as little loss of quality as possible.
I have tried the following code using Magick.net, but it could only reduce the weight to 1.5MB.

Dim fi As New FileInfo("C:\test\sample.jpg")
Console.WriteLine("Bytes after:  " + fi.Length.ToString)

Dim optimizer As New ImageOptimizer()
optimizer.Compress(fi)
fi.Refresh()

Console.WriteLine("Bytes after:  " + fi.Length.ToString)

I would like to reduce the file size of my images to about 50% of their original size.
Is there any way to compress the images as much as possible?
I would appreciate it if you could let me know, even if it is a paid library.

(However, we do not intend to use a service that charges by the number of images.)

2
  • Jpeg save functions usually have a quality parameter (100 to 0) which allows to specify the desired quality. The lower the quality the smaller the files. As compression depends on image content and existing quality setting yo have to try what compression setting ends up in what size reduction.
    – Robert
    Jul 11, 2022 at 9:56
  • Hi Robert, thanks for your comment. I fully understand that. But on top of that, I would like to reproduce a service like TinyPNG on WinForms.
    – T.K
    Jul 11, 2022 at 10:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.