Comments (13)
This issue came from iphone it self, see this http://stackoverflow.com/a/22506787/4476788
Case closed
from bulletproof.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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?
from bulletproof.
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.
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)
- Minor improvements HOT 2
- Packagist version outdated? Util functions not found thru namespace? And other bugs. HOT 2
- How do i upload multiple image, rename and create thumbnail HOT 4
- File upload not working in linux server HOT 2
- How to Save in JPG (instead of JPEG)? HOT 4
- Svg upload ? HOT 2
- Bulletproof - change image that was uploaded HOT 9
- Upsizing not working HOT 7
- Error! directory 'bulletproof' could not be created
- Readme examples are referencing wrong methods (setLocation is now setStorage ) HOT 4
- Uploading Image From a URL HOT 1
- The README.md shows "setLocation" as a valid function, when said function has appearently been renamed to "setStorage" HOT 1
- Dependency Dashboard
- Constant 'FILTER_SANITIZE_STRING' is deprecated HOT 2
- setName fails to work... HOT 1
- Image format error HOT 9
- Object of class UnwindExit could not be converted to string HOT 3
- PHP Deprecated: Return type of Bulletproof\Image HOT 1
- uploaded image is missing a name
- setName() doesn't set the name for uploaded file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bulletproof.