I want to reduce file size and store it in the root folder ex. if I upload a user image from IFromFile then there should be two files stored first the original one and the other one compressed I have tried GZip but it is producing zero byte file size
Loading
Marvin ReidPosted Oct 9, 2023, 6:07 PM
You can use the RasterCodecs class to apply Jpeg compression which is a common way to reduce file size. One can manipulate the Q Factor to determine the degree of loss applied from the compression. For a higher compression ratio, you can set the QualityFactor to a bigger number. For less compression you can keep it at 2. Here is an example:
https://www.leadtools.com/help/sdk/main/api/file-formats-jpeg-and-lead-compressed-jpg-j2k-jp2-jpm-jls-cmp-and-cmw.html
https://www.leadtools.com/help/sdk/v22/dh/co/codecsjpegsaveoptions-qualityfactor.html
Amit MohantyPosted Sep 27, 2023, 10:32 AM
You can use a ImageSharp library to reduce file size. Check the below example.
First, make sure you have ImageSharp installed.
Then you can create a method to compress and save the uploaded image.
Now in your code call the CompressAndSaveImageAsync method to process and save the compressed image: