1

I need code which which allow me to compress JPEG Images which are approximately 3,000 KB in file size to around 400-800KB using Magick.Net on Visual Studio.

Thus far I have tried the following below however this doesn't compress the image into a small enough file size which i require.

`

FileInfo info = new FileInfo("c:\\testimage.jpg");
ImageOptimizer optimizer = new ImageOptimizer();
Console.WriteLine("Bytes before: " + info.Length);
optimizer.LosslessCompress("c:\\testimage.jpg");
info.Refresh();
Console.WriteLine("Bytes after: " + info.Length); 

`

As detailed before, my intentions are to achieve compression to around 400-800 KB for each image, which will then allow to complete the next task.

jwhiteuc
  • 11
  • 4
  • Is there a property/parameter which define compression level (image quality?) as a number? You can write a loop which will find *the best* (or good enough) value by trying it and observing results. Not the fastest method. Maybe trying maximum and minimum value (to get range) and then doing some kind of approximation will be better. – Sinatr Jul 11 '19 at 07:46
  • @Sintar Im not too sure that there is a define compression level the code above was taken from https://github.com/dlemstra/Magick.NET/blob/master/samples/Magick.NET.Samples/LosslessCompression.cs – jwhiteuc Jul 11 '19 at 07:49

0 Answers0