ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Jpeg image Header and Exif DPI

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
lago Posted - Mar 31 2017 : 08:20:29
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!
6   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 04 2017 : 17:20:02
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
w2m Posted - Apr 01 2017 : 11:02:06
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
lago Posted - Apr 01 2017 : 04:46:04
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.

:?
w2m Posted - Mar 31 2017 : 14:45:59
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
lago Posted - Mar 31 2017 : 14:42:00
Hello, thanks for your reply. Its the same, not save EXIF. :-?
w2m Posted - Mar 31 2017 : 14:10:08
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