Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is recommended to support jpg exif. #37

Open
winddriver opened this issue Jan 19, 2024 · 4 comments
Open

It is recommended to support jpg exif. #37

winddriver opened this issue Jan 19, 2024 · 4 comments

Comments

@winddriver
Copy link

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.

@galfar
Copy link
Owner

galfar commented Apr 24, 2024

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.

@winddriver
Copy link
Author

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

@galfar
Copy link
Owner

galfar commented May 5, 2024

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.

@winddriver
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants