ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Rotation of an Image without a loss of quality
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

DRIGUS

12 Posts

Posted - May 19 2020 :  08:36:03  Show Profile  Reply
Hello,
I want to build an Application that rotates an Image clockwise or counterclockwise. Whereby the quality of the Image should not be changed. I use the following code to implement the Funcionality:

procedure tImageEnItem.RotationCounterClockwise;
begin
  case FImage.IO.Params.EXIF_Orientation of  
    0: FImage.IO.Params.EXIF_Orientation := 8;
    1: FImage.IO.Params.EXIF_Orientation := 8;
    8: FImage.IO.Params.EXIF_Orientation := 3;
    3: FImage.IO.Params.EXIF_Orientation := 6;
    6: FImage.IO.Params.EXIF_Orientation := 1;
  end;

  FImage.IO.Params.EXIF_HasEXIFData := True; 
  FImage.IO.Params.TIFF_Orientation := FImage.IO.Params.EXIF_Orientation;
  SaveFile;
  OpenFile;
end;

Now I have the Problem, that my Code changes the Image. I added an Example.

The original One is the following:

After 100 rotations I get the following result:



Am I doing something wrong?
Greetings

xequte

5227 Posts

Posted - May 19 2020 :  16:41:37  Show Profile  Reply
Hi

JPEG is a lossy format, which means that every time it is saved a little bit of the image information is thrown away to make it compress better.

To negate or reduce this, you have two options:

1. Lossless JPEG rotation:

If you use the JpegLosslessTransform2 method, then there will be no reduction in quality:

https://www.imageen.com/help/ImageEn/JpegLosslessTransform2.html

In fact, there is already a method to automatically load, rotate and then save images based on EXIF data:

https://www.imageen.com/help/ImageEn/IEAutomaticallyRotateImageFile.html


2. Specify a much higher JPEG quality value

You don't show your saving code, so I can only guess you are using a lower or default JPEG quality. You should increase that:

https://www.imageen.com/help/ImageEn/TIOParams.JPEG_Quality.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

DRIGUS

12 Posts

Posted - May 20 2020 :  09:43:57  Show Profile  Reply
Hey Nigel,
Thank you for you're Help.
I already set the JPEG-Quality at 100%.
But the clue, with the jpeglosslessTransform2 method, helped me.
Thanks a lot.


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: