Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6963131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:44:59+00:00 2026-05-27T15:44:59+00:00

Ive created an image gallery with php and mysql, incorporating several ways to add

  • 0

Ive created an image gallery with php and mysql, incorporating several ways to add images & ability to sort by addition method and/or category. After noticing some images from apple devices showed up with the ‘wrong’ orientation, I created another page to edit orientation and other file info, then save said changes back to file and db. Only after I thought I had solved this problem did I view the altered images on an apple device, only to realize that image was now in ‘wrong’ orientation on said device. I’ve been googling this, but can’t quite figure out exactly what I need to learn now to deal with images from apple devices in this situation. A shove in the right direction would be greatly appreciated.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:45:00+00:00Added an answer on May 27, 2026 at 3:45 pm

    Forgot I posted this. I figured out how to handle the orientation issue so I thought I’d share. Seems simple now. I’ve since recreated this project using Codeigniter. CI is great and saves a lot of time, but I’m glad I wrote it all myself the first time. I sure learned more that way.

    First, if the file is a jpg, I get the EXIF data with PEL .

    $new is the uploaded file to be checked for orientation.

           $this->load->library('pel/PelJpeg');
    
    
           if($ext == 'jpg'){
                $pdw= new PelDataWindow(file_get_contents($new));
                if(PelJpeg::isValid($pdw)){
                    $input_jpg = new PelJpeg($new);
                    $exif = $input_jpg->getExif();
                }
            }
    

    Then if EXIF exists, get the orientation value and run it through a switch statement, rotate it accordingly and then reset the orientation value. I’m using image_moo and Codeigniter, but this can obviously be changed to use any image manipulation library.

    I’m honestly not sure if all those IF statements need to be there, but I kept running into trouble with jpg’s that only included some EXIF info and would blow up the script without them.

     if($exif !== NULL){
     if($tiff = $exif->getTiff()){
     if($ifd0 = $tiff->getIfd()){
     if($orient = $ifd0->getEntry(PelTag::ORIENTATION)){
     $this->image_moo->load($new);
    
     //find the orientation value from the orientation tag.  May be a better way, but this works for me.                                    
     $orientation = str_replace(' ', '', $orient);
     //The orientation value from the orientation tag is after 'Value:'
     if (($tmp = strstr($orientation, 'Value:')) !== false) {
          $str = substr($tmp, 6, 1);
     }
    
     switch ($str)
     {
         // up is pointing to the right
         case 8:
           $this->image_moo->rotate(90);
           $orient->setValue(1);
           break;
         // image is upside-down
         case 3:
           $this->image_moo->rotate(180);
           $orient->setValue(1);
           break;
         // up is pointing to the left
         case 6:
           $this->image_moo->rotate(270);
           $orient->setValue(1);
           break;
         // correct orientation
         case 1:
           break;
           }
         $this->image_moo->save($new,TRUE);
         if ($this->image_moo->errors) print $this->image_moo->display_errors();
         $this->image_moo->clear();
     }
     }
     }
     }
    

    Hope this will be helpful to someone else struggling with the same issues.
    If you see anything that could be improved, please let me know. But this works great for me.

    Mark

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive created a portfolio website for myself, there is a gallery which users can
Ive got an assignment to create an image gallery using flickr - this has
I've created a gallery so that various images are ordered into columns. The images
I'm loading a folder full of images in, to create a jQuery Image Gallery.
Basically I receive the Image's URI from the Gallery, then created a Bitmap and
I've got a simple PHP image gallery where the PHP reads data from a
I'm stumped. I've created an upload image process that works in every browser except
Consider the following mock-up image I've created: I am new with working with InfoPath
Morning all, I've created a custom control with an image property. That image property
I've created a blog main page using PHP and have included a sidebar and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.