Comments (3)
Ahhhh, now I understand ;-) I'll try to explain...
from image-resizer-service.
In some weird cases, idk why, image metadata gets corrupted. When that happens, different viewers show the image in different orientation and this resize tool can't handle it. Opening the image in sth like PS and re-exporting it or cleaning the metada solves the problem for a specific file.
from image-resizer-service.
That happens mainly if you upload stuff from an iOS Device...
The iPhone/iPod/iPad wants to be a real camera in landscape. And if you hold your phone like this, it really feels like a camera, it has the lenses in the upper right corner, thats ok. No matter how you do your photo, it will be delivered like you make it. So if you hold it in landscape, this side is on the top, if you hold it in portrait, this side is the top.
And because it was to be a correct device it puts extra information in the meta data how it was hold while making the picture. It is not intended to be corrected by the orientation, it just says "this was my orientation".
And this script (like many others) try to correct the orientation by the metadata, but thats not needed. So the trick is pretty simple. Just throw away all the metadata when you save the image in the backend and you won't have any issues. Then all pictures portrait, landscape, upside down look good and like you made them.
Coming from php, i did it like this:
` if(@is_array(getimagesize($this->path . $newFileName))){
$img = new \Imagick($this->path . $newFileName);
$orientation = $img->getImageOrientation();
switch($orientation) {
case \Imagick::ORIENTATION_BOTTOMRIGHT:
$img->rotateimage("#000", 180); // rotate 180 degrees
break;
case \Imagick::ORIENTATION_RIGHTTOP:
$img->rotateimage("#000", 90); // rotate 90 degrees CW
break;
case \Imagick::ORIENTATION_LEFTBOTTOM:
$img->rotateimage("#000", -90); // rotate 90 degrees CCW
break;
}
// Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image!
$img->setImageOrientation(\Imagick::ORIENTATION_TOPLEFT);
$img->stripImage();
$img->writeImage($this->path . $newFileName);
}`
from image-resizer-service.
Related Issues (17)
- Unable to open Image HOT 4
- Cant resize image get 500 HOT 2
- Unable to open image HOT 2
- Headers aren't passed to cloudfront HOT 4
- Spaces HOT 1
- Migration to node 10 HOT 8
- How to ignore files?
- store images in another bucket HOT 1
- Security: malicious user could waste resources
- 502 when image is too large
- Image quality degraded
- Unable to open image
- Question-migration node 12x
- Migrating the Node 14.x
- Cloudfront -> Api Gateway Setup HOT 1
- A potentail risk in the image-resizer-service to escalate IAM permission for S3 bucktes 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 image-resizer-service.