SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    camera image orientation issue

    Hi there,

    I'm working on a CMS which allows the user to crop uploaded images.

    Everything works fine when I test with random digital imagery which I have on my hard-drive. When I come to test using the client's digital images he has given me, all the images come out landscape regardless of their orientation.

    I am resizing the images programmatically using PHP. Even though my OS is happy with this flashy "portait" orientation idea, getimagesize() returns landscape dimentions. So when the files are resized and saved by PHP, they are all landscape. My guess is the client's camera is pretty old skool, and cannot distinguish between landscape and portrait orientation. He would then (I guess) orientate them manually using his PC. This data, for whatever reason, is not saved to the jpeg file, or at least not in a way that PHP can read.

    Short of batch cropping the images in Photoshop, and then re-saving them, which of course is no good to my client, is there anything I can do to get these images the right way round!?

    Many thanks,
    Mike

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Strange, but if so, can you still count the pixels of the image? Actually, maybe you could upload of these images for us to look at and/or test?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Its probably the EXIF Orientation Tag. Some software take it into consideration others ignore it.
    ImageMagick has an auto-orient option to handle it.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys for your replies.

    ImagicMagick seems awesome, but unfortunately my server doesn't have it installed.

    However, EXIF is loaded on my server's php build. Fandabidosy. And yes, exif_read_data() returns an extensive array, of which 'Orientation' contains a number between 1 and 8, which gives the orientation of the image. You can then use rotateimage() on a GD resource (assuming you have GD installed), to rotate the image. Bonza.

    For anyone who's interested there's a great post about it here:
    http://www.neilyoungcv.com/blog/code...ientation-fix/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •