• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

JPG Resolution

Started by davem, 1 November 2011, 11:44:59

Previous topic - Next topic

davem

Do I understand from this topic http://galfar.vevb.net/imaging/smf/index.php/topic,283.0.html that the library supports the print resolution of JPEGs (in pixels per inch or pixels per cm)? How to set it up? Thanks!

Galfar

You can get print resolution from JPEGs (provided that this info is embedded inside) using metadata framework.
It's not stored in image itself so you need to keep track of it if you want to later save the values that were loaded.

Code (pascal) Select
type
  // defined in Imaging.pas
  TResolutionUnit = (
    ruSizeInMicroMeters, // value is pixel size in micrometers
    ruDpi,               // value is pixels/dots per inch
    ruDpm,               // value is pixels/dots per meter
    ruDpcm               // value is pixels/dots per centimeter
  );

var
  XRes, YRes: Single;
  ResUnit: TResolutionUnit;

... load image ...

ResUnit := ruDpi;
if GlobalMetadata.GetPhysicalPixelSize(ResUnit, XRes, YRes) then
begin
  ... print resolution present, do something with it
end;

... do something with image
GlobalMetadata.SetPhysicalPixelSize(ResUnit, XRes, YRes, True)
... save image


Checkout TMetadata class in Imaging.pas for implementation details.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk