imaginglib icon indicating copy to clipboard operation
imaginglib copied to clipboard

It is recommended to support jpg exif.

Open winddriver opened this issue 1 year ago • 4 comments

Some photos taken with mobile phones need to be rotated through the Orientation in the exif to display correctly.

But at present, imaginglib does not decode the exif information, and it is impossible to determine the correct rotation angle of the picture after loading the jpg picture with TSingleImage

Hope imaginglib can add relevant functions, thanks.

winddriver avatar Jan 19 '24 05:01 winddriver

Some minimal reader for EXIF orientation + GPS (these two are most interesting for me) wouldn't be too difficult - I've even found some old notes I made for this some years ago.

Writing the EXIF though, I'll pass on that - ideally you keep the whole original EXIF from loaded file and write it back when saving the file - updated based on modifications you did with the files. Sounds like "application level" rather than "library level" concern.

galfar avatar Apr 24 '24 00:04 galfar

But at present, imaginglib loads the jpg picture and does not decode the exif completely, so the information related to the direction of the picture cannot be read. Once the picture is modified and saved again by methods such as Resize, the direction information is lost

winddriver avatar May 05 '24 02:05 winddriver

What Imaging could realistically do is load the whole EXIF structure on load and have it accessible as a binary blob (plus parse a minimal set of properties such as orientation) and on save optionally put the EXIF blob to file. Between load and save, the EXIF blob could be fed to something like CCR Exif to make updates based on your modification of the picture.

galfar avatar May 05 '24 19:05 galfar

Here are my test projects and test results

In the screenshot, 1.jpg is the original image, and 2.jpg is the image after SaveToFile.

You can see that the exif information has been lost, so the picture cannot be rotated in the correct direction.

image

TestExif.zip

program TestExif;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  ImagingClasses;

procedure RunTestExif;
var
  LImage: TSingleImage;
begin
  LImage := TSingleImage.Create;
  try
    LImage.LoadFromFile('1.jpg');
    LImage.SaveToFile('2.jpg');
  finally
    FreeAndNil(LImage);
  end;
end;

begin
  RunTestExif;
end.

winddriver avatar May 06 '24 06:05 winddriver