metty
metty

Reputation: 55

get metric size of image in cpp

I want to read the metric sizes from an image in C++. In Octave I could do this up to now:

IM.info = imfinfo(path_to_image);
IM.info.ResolutionUnit
IM.info.XResolution
IM.info.YResolution 

For example, when I export a PNG on Inkscape, I specify DPI and the pixel size of the image. So this information should be available in the metadata right? I find many examples of how to read the pixel sizes, but none that can read metric information. What is the best way to do this?

Upvotes: 0

Views: 71

Answers (1)

eerorika
eerorika

Reputation: 238321

The C++ standard library does not have functions for reading PNG files. You will need to parse the file.

According to the specification Chapter 11. PNG Options and Extensions, the relevant chunk should be Physical Pixel Dimensions (pHYs).

Upvotes: 1

Related Questions