Compress JPEG in Visual Studio with Magick.net?
Posted: 2019-07-11T00:45:29-07:00
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.
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.
Thus far I have tried the following below however this doesn't compress the image into a small enough file size which i require.
Code: Select all
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.