No, sorry, that image really is width 4032 and height 2268.

You see, cameras always produce the same resolution image. If it's a 4032x2268 
sensor, it will make a 4032x2268 image no matter how you are holding the 
camera. The camera has an orientation sensor, and that is used to set the 
Orientation metadata in the saved image file, to reflect how to display the 
image so that it will match the way you were holding the camera. That's a lot 
simpler and cheaper than actually rotating the image pixels.

The picture was taken with an iPhone, so I'll presume that you have a good 
chance of having a Mac. Open your image with Preview.app. You'll see that it 
appears oriented correctly, but if you hit Cmd-I (for info), and select the 
"General" tab, and you'll see that it says the height is 2268 and width is 4032 
and will tell you the orientation is 6 (meaning it should be rotated 90 degrees 
clockwise when displayed).

With the OpenImageIO API, you can retrieve the "Orientation" metadata like this:

    int orientation = spec.get_int_attribute("Orientation");

It's really the responsibility of the display program to draw it with the 
hinted orientation.

Though if you wish to actually transform it into a 4032x2268 using OpenImageIO 
calls, you can

    ImageBuf rotated = ImageBufAlgo::reorient(inp);

This will apply whatever Orientation is in inp's metadata by actually rotating 
the image (and in the resulting image, the Orientation metadata will be 0, 
meaning that it should be displayed with the (0,0) pixel in the upper left 
corner).


> On Dec 28, 2022, at 11:36 PM, 0ices <zeroi...@qq.com> wrote:
> 
> The width of this image is 2268 and the height is 4032, but the width 
> obtained through oiio is 4032 and the height is 2268.
> here is my code, how can I get the right result
> 
> ImageBuf inp(input_path, 【cache】);
>     const ImageSpec& spec = inp.spec();
>     const int nch = spec.nchannels;
>     const int width = spec.width;
>     const int height = spec.height;
> <IMG_1559.JPG>_______________________________________________
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

--
Larry Gritz
l...@larrygritz.com





_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to