imaginglib
imaginglib copied to clipboard
It is recommended to support jpg exif.
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.
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.
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
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.
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.
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.