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
 Jpeg image Header and Exif DPI
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

lago

40 Posts

Posted - Mar 31 2017 :  08:20:29  Show Profile  Reply
Hi, I have a question about the following:

I want to change the DPI resolution of an image, I do it like this:

This-> ImageEnIO1-> ParamsFromFile ("file.jpg");
This-> ImageEnIO1-> Params-> Dpi = 300;
This-> ImageEnIO1-> InjectJpegEXIF ("file.jpg");

It does this correctly, but only saves the DPI value in the JPEG header not in the EXIF metadata.

For example, if I open file.jpg with PhotoShop in the properties shows the change to 300 DPI. But in %EXIF-Horizontal-Resolution and %EXIF-Vertical-Resolution follows 1/72 inch

How could I save it also in EXIF?

Thank you!

w2m

USA
1990 Posts

Posted - Mar 31 2017 :  14:10:08  Show Profile  Reply
Maybe you should try
ImageEnView1.IO.Params.DpiX := 300;
ImageEnView1.IO.Params.DpiY := 300;
I am unsure if this will solve the problem however.


Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

lago

40 Posts

Posted - Mar 31 2017 :  14:42:00  Show Profile  Reply
Hello, thanks for your reply. Its the same, not save EXIF. :-?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 31 2017 :  14:45:59  Show Profile  Reply
Does InjectJpegEXIF return true?
You could also just set
ImageEnIO1.ParamsFromFile('file.jpg');
ImageEnIO1.Params.Dpi := 300;
ImageEnIO1.Params.EXIF_XResolution := 300;
ImageEnIO1.Params.EXIF_YResolution := 300;
ImageEnIO1.InjectJpegEXIF('file.jpg');
Does this work?

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

lago

40 Posts

Posted - Apr 01 2017 :  04:46:04  Show Profile  Reply
It's strange, since other software like Photoshop or PhotoME shows the new
resolution correctly. But when I read the metadata from Imageen
(GetExifTagList) in the values of the %EXIF-Horizontal-Resolution and
%EXIF-Vertical-Resolution variables do not change.

:?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Apr 01 2017 :  11:02:06  Show Profile  Reply
Nigel said in a earlier post you need to call ChangeResolution as well. "Working with DPI is rather a headache. 300DPI = 762 Pixels per CM, so for an image of 1000 x 1500 MM (100 x 150 CM, for our American readers ;-) you need not only set the DPI to 300, but also resize the image to 76,200 x 114,300 pixels."

So if you open the ../InputOutput/Exif demo and add this code:
procedure TForm1.ChangeResolution1Click(Sender: TObject);
begin
  ImageEnView1.ChangeResolution(UpDown1.Position, rfNone);
  ImageEnView1.Update;
  StringGrid1.Cells[1, 5] := floattostr(UpDown1.Position);
  StringGrid1.Cells[1, 6] := FloatToStr(UpDown1.Position);
  StringGrid1.Cells[1, 32] := IntToStr(ImageEnView1.IEBitmap.Width);
  StringGrid1.Cells[1, 33] := IntToStr(ImageEnView1.IEBitmap.Height);
  ImageEnView1.IO.Params.EXIF_XResolution := StrToIntDef(StringGrid1.Cells[1, 5], 0);
  ImageEnView1.IO.Params.EXIF_YResolution := StrToIntDef(StringGrid1.Cells[1, 6], 0);
  ImageEnView1.IO.Params.EXIF_ExifImageWidth := StrToIntDef(StringGrid1.Cells[1, 32], 0);
  ImageEnView1.IO.Params.EXIF_ExifImageHeight := StrToIntDef(StringGrid1.Cells[1, 33], 0);
  case ImageEnView1.IO.Params.FileType of
    ioJPEG : ImageEnView1.IO.InjectJpegEXIF(FileListBox1.FileName);
    ioTIFF : ImageEnView1.IO.InjectTIFFEXIF(FileListBox1.FileName);
  end;
  ImageEnView1.IO.SaveToFile(FileListBox1.FileName);
end;

The Exif dpi and Exif Width and Exif Height will be set. WARNING - The actual dimensions of the image will also be changed.

When this code is executed both the EXIF Resolution parameters and EXIF Image Dimensions will be set and the actual dimensions of the image will change to the corresponding to the resolution of the image. ChangeResolution is similar to resampling the image except instead of setting the new width and height of the image, these values are calculated by the resolution (DPI) value.


Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

xequte

38611 Posts

Posted - Apr 04 2017 :  17:20:02  Show Profile  Reply
Hi

The EXIF values: EXIF_XResolution, EXIF_YResolution, EXIF_ExifImageWidth, EXIF_ExifImageHeight are not affected by bitmap size or DPI.

Are you saying that Bill's code:


ImageEnIO1.ParamsFromFile('file.jpg');
ImageEnIO1.Params.EXIF_XResolution := 300;
ImageEnIO1.Params.EXIF_YResolution := 300;
ImageEnIO1.InjectJpegEXIF('file.jpg');


Does not change the value of EXIF_XResolution and EXIF_YResolution in file.jpg?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: