Saving Jpeg file as original file

I have a Jpeg file which is an 8mb of size. Using the code below, the new jpg file generated by aspose Image decrease it file size significantly (1mb) and as far I understand, I would assume that the file size should remain the same since I don’t do any image processing with the file. Is there any compression made by aspose when saving? Or is there a way to preserve its original file size?

public void SaveFile(string orignalFilePath)
{
using (var image = Image.Load(orignalFilePath))
{
image.Save(“NewJpg.jpg”);
}

    }

@MarkMariano,

Can you please share the source JPEG file along with generated output that we test and verify on our end. Please also consider using latest Aspose.Imaging for .NET 20.6 on your end.

DSCF9534.JPG (3.9 MB)
NewJpg.jpg (924.6 KB)

These are my test files. “NewJpg.jpg” is the output of Aspose using 20.6.0 i think this is the latest

@MarkMariano,

Please try using following code on your end.

    public static void TestJpegSave()
    {
        String path = @"C:\Users\mudas\Downloads\";
            using (var image = Image.Load(path+ "DSCF9534.jpg"))
            {
            JpegOptions opts = new JpegOptions()
            {
                Quality = 100,

            };
                image.Save(path+"SaveJpg.jpg",opts);
            }

    }

There are still small difference between the two files however a difference with less than 100 kb, However tried another file and surprisingly the file size increase into 13.2mb. I attached the other file that I tested.

Is there any work around for this or Can aspose Image process the file as is if there are no changes in the Image?Original_File_6.8.jpg (2.3 MB)

@MarkMariano,

This issue need to be verified as suggested example is working in one case and failing in other. A ticket with ID IMAGINGNET-4004 has been created to further investigate and resolve the issue. We will share the feedback with you as soon as it will be fixed.

@mudassir.fayyaz do we have an update on IMAGINGNET-4004?

@MarkMariano,

We have internally investigated the issue in detail. Actually. an image in Jpeg format is compressed with loss - this means that the compressed file will no longer correspond to the original 1 in 1, but the distortion may not be noticeable to the eye. When compressing an image into this format, the quality is set, the higher the quality, the lower the degree of distortion and the larger the file size. The resulting Jpeg does not contain information about the compression ratio. Therefore, it is not possible to obtain the same image upon re-compression. You can only get something similar by choosing the quality.

Hi @mudassir.fayyaz,

Follow up question, Is there anyway of writing back xmp metadata without recompressing.

Thanks,
Mark

@MarkMariano,

I have associated the information in our issue tracking system and will get back to you with feedback as soon as possible.

@mudassir.fayyaz any feedback on this?

Also additional question. Can Aspose have a option to generate a sidecar file (.xmp) in writing XMP?

@MarkMariano

We have added a new ticket with ID IMAGINGNET-4072 for support of writing XMP metadata without re-compressing. I have linked additional comments in our issue tracking system with that too.