Giter VIP home page Giter VIP logo

Comments (13)

mjniuz avatar mjniuz commented on June 2, 2024 1

This issue came from iphone it self, see this http://stackoverflow.com/a/22506787/4476788

Case closed

from bulletproof.

samayo avatar samayo commented on June 2, 2024

Can you clarify a bit more? This image upload has nothing to do with modifying the image code, so it can't rotate it by any means.

from bulletproof.

ArneAnka avatar ArneAnka commented on June 2, 2024

Alright sorry about that.

When using bulletproof and uploading from iPhone (only device i have tested on), the images gets rotated 90° counter clockwise. And if shooting in landscape mode, the image is rotated 180° counter clockwise.

Images is displayed on device in the right orientation, but on a computer, the error occurs.

See image: http://imgur.com/LdDaBjY

from bulletproof.

samayo avatar samayo commented on June 2, 2024

Well, this is weird. All I can say before going further is, 1) make sure you are using latest version of bulletproof which is at v.2.0.1 2) check if you are using other code that may be interfering with the images orientation.

from bulletproof.

ArneAnka avatar ArneAnka commented on June 2, 2024

Yes its weird. Im using @Version 2.0.0 and no other code is interfering. Bulletproof is doing all work for me. According to http://regex.info/exif.cgi the orientation of image is "Rotate 90 CW". When viewing image on computer (mac/finder) the image is in the "right" way. But viewing image on regex.info/exif.cgi, the image appears turned CW. But viewing it in my app on the device (iphone), it is orientated "the right way".

can't wrap my head around this

from bulletproof.

samayo avatar samayo commented on June 2, 2024

I have no clue honestly. I think you should ask about this on stackoverflow or reddit/r/php and see what others can make of it.

from bulletproof.

ArneAnka avatar ArneAnka commented on June 2, 2024

Asked at reddit, but no good answers. This is what i came up with:

public function moveUploadedFile($tmp_name, $destination)
    {   
        if(move_uploaded_file($tmp_name, $destination)){
            $this->image_rotation();
            return true;
        }
}
    public function image_rotation(){
        /* Check if the image is rotated,
         * and if it's rotates. Fix it!
         */
        // $filename = __DIR__ . '/'.$this->location .'/'. $this->name . '.' . $this->mime;
        $filename = $this   ->fullPath;

        $exif = exif_read_data($filename);
        if (isset($exif['Orientation']))
        {
          switch ($exif['Orientation'])
          {
            case 3:
             // Need to rotate 180 deg
                  $degrees = 180;
                  break ;

            case 6:
              // Need to rotate 90 deg clockwise
                  $degrees = -90;
                  break ;

            case 8:
              // Need to rotate 90 deg counter clockwise
                  $degrees = 90;
                  break ;
          }

            if (preg_match("/jpg|jpeg/", pathinfo($filename, PATHINFO_EXTENSION)))
            {
                $image_source = imagecreatefromjpeg($filename);
                $rotate = imagerotate($image_source, $degrees, 0);
                imagejpeg($rotate, $filename, 100);

            }
            if (preg_match("/png/", pathinfo($filename, PATHINFO_EXTENSION)))
            {
               $image_source = imagecreatefrompng($filename);
               $rotate = imagerotate($image_source, $degrees, 0);
               imagepng($rotate, $filename, 100);
            }
            if (preg_match("/gif/", pathinfo($filename, PATHINFO_EXTENSION)))
            {
               $image_source = imagecreatefromgif($filename);
               $rotate = imagerotate($image_source, $degrees, 0);
               imagepng($rotate, $filename, 100);
            }

            imagedestroy($image_source); //free up the memory
            imagedestroy($rotate);  //free up the memory

        }
}

Don't know if it is the best way to go, but seems to work!

from bulletproof.

samayo avatar samayo commented on June 2, 2024

hmm, I've thought about this issue, and I just can't decide to implement this feature, because as stated in reddit, the iphone browsers are making the change. So, it'll be just bloating the lib with trivial features. Thanks for the help though

from bulletproof.

mjniuz avatar mjniuz commented on June 2, 2024

Still in issue with version 2.0.5
This issue from picture that taken by iphone, and when I try to resize, it will turns to 90 degree

from bulletproof.

samayo avatar samayo commented on June 2, 2024

Hi @mjniuz Yes, this issue was beyond the scope of the project so I did not add it to bulletproof. Let me know if @ArneAnka's solution worked for you, so I can maybe integrate his code into bulletproof

from bulletproof.

jsantari avatar jsantari commented on June 2, 2024

This is an issue from my Android phone also. I've implemented ArneAnka's function which does fix the rotation problem. However when bulletproof resizes the image I get this black strip on the side of the image. If I don't use the resize function no problem?

5a19748d4bf4f4 91452642_ohkifglejpmnq

from bulletproof.

samayo avatar samayo commented on June 2, 2024

Sorry about this. bulletproof isn't supposed to do anything other than upload images with security. So, it's hard to implement functions and feature to support browser features across many. Maybe you should find a more streamlined library to rotate the images and that'll probably fix your problem.
Checkout http://image.intervention.io/

from bulletproof.

jsantari avatar jsantari commented on June 2, 2024

Thanks for the response. I know what the problem is but not sure how to fix it. Bulletproof sets the imgWidth an imgHeight values before the image is rotated by the ArneAnka image_rotation() function when implement at described. Not sure how that could be fixed in your code. Would have to reset those to the values of the rotated image. I'll take at look at the other library.

from bulletproof.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.