CodeIgniter Forums
Get orientation (landscape/ portrait) of image - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Get orientation (landscape/ portrait) of image (/thread-20601.html)



Get orientation (landscape/ portrait) of image - El Forum - 07-15-2009

[eluser]mvdg27[/eluser]
Hi,

Maybe I'm overlooking something in the CI docs (and PHP docs), but is there an easy way to get the orientation of an image?

Basically I want to know whether an uploaded imagefile is portrait or landscape, and then resize it accordingly.

Any ideas?

Thanks!


Get orientation (landscape/ portrait) of image - El Forum - 07-15-2009

[eluser]Johan André[/eluser]
If you use CI Upload-library use $this->upload->data() (which returns an array) and check it for key "image_width" and "image_height".

If width > height then image is landscape, if width < height then image is portrait.
If width = height then image is square! Smile


Get orientation (landscape/ portrait) of image - El Forum - 07-15-2009

[eluser]mvdg27[/eluser]
Yeap .. The upload library does the trick. I was searching for image_width and image_height in the image library. This works great.

Thanks


Get orientation (landscape/ portrait) of image - El Forum - 07-15-2009

[eluser]jdfwarrior[/eluser]
I forgot upload class had it. I knew it was somewhere. I was going to suggest the php getimagesize function.