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