Comments (19)
The problem is that the standard image
library doesn't read (or write) any EXIF data, so none of the imaging libraries support it either. Looks like our best bet is to read the orientation field and rotate the image before resizing.
Rough sample code:
import "github.com/rwcarlsen/goexif/exif"
src := io.Reader(image)
x, err := exif.Decode(src)
if err != nil {
log.Fatal(err)
}
orientation, err := x.Get(exif.Orientation)
switch orientation {
case: "90 CW":
src.Rotate(90)
case "90 CCW":
src.Rotate(-90)
}
from vip.
Makes sense. Looking that bug it's just waiting for somebody to pick it up and fix it.
from vip.
Make sure to measure performance before and after this change. I'm very wary of changes that negatively impact cold cache hits in Vip. If it causes a regression we should look into how it can be improved before distributing the change.
from vip.
It appears as though the orientation itself is actually recorded as an integer between 1–8. (Presumably 0 is "no rotation".) Most tools that display the value translate that integer into some human readable string like "90 Clockwise".
More data here, pp 30–35: http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf
from vip.
Check with the Android team. They're pros at this because samsung. @nick-fedesna dealt with EXIF orientation woes on dScout if I remember correctly.
from vip.
That is correct, come see me if you have EXIF questions.
from vip.
@scottferg Well, I'm pretty sure it going to cost at most the time to do imaging.Rotate()
. However, we should be able to add runtime.GOMAXPROCS(runtime.NumCPU())
and imaging
will parallelize whatever processing it can.
Also note that imaging
also claims to support GIF
files now, but I don't think it makes any promises about animated GIFs.
from vip.
@nick-fedesna You have a reference that maps the orientation integers to rotation amounts/directions?
from vip.
from vip.
from vip.
Did imaging
state that it works concurrently?
Regardless, the cost can be optimized. image.Image
is a reader, so we can buffer. Measure the before and after and we'll move on from there.
from vip.
also: https://developer.android.com/reference/android/media/ExifInterface.html#ORIENTATION_ROTATE_270
for the constants
from vip.
As noted by @nick-fedesna, We can probably safely ignore 1, 2, 4, 5, and 7. I'll map:
6 -> 90
3 -> 180
8 -> 270
All clockwise.
from vip.
@nick-fedesna: VIP contributor
On Nov 18, 2014 4:55 PM, "Nick Fedesna" [email protected] wrote:
also:
https://developer.android.com/reference/android/media/ExifInterface.html#ORIENTATION_ROTATE_270
for the constants—
Reply to this email directly or view it on GitHub
#41 (comment).
from vip.
from vip.
Imaging package uses parallel goroutines for faster image processing. To achieve maximum performance, make sure to allow Go to utilize all CPU cores.
https://github.com/disintegration/imaging#parallelization
from vip.
Cool cool, sometimes people look at GOMAXPROCS
as a silver bullet. Important to make sure it's legit.
from vip.
Any movement on this one? I'll rotate images before upload if I need to.
from vip.
I'm working on this in conjunction with #46 since it requires using basically the same libraries on file ingress.
from vip.
Related Issues (20)
- video with elastic transcode on media-proxy HOT 8
- Vip mangles transparency HOT 3
- Add environment variables to the README
- gif resizing
- Become sentient
- Support CMYK JPEG files HOT 4
- Try grabbing image size without decoding the whole image HOT 1
- can't seem to upload an image to vip... probably user error HOT 14
- [suggestion] smart crop HOT 2
- Uploading images via HTTPS should return a secure URL for getting the image
- `broken pipe` error instead of 413 when using RetroFit
- Clean up docs
- Update drone.yml to push build to vokal DockerHub on successful merge HOT 1
- How can we tag specific release versions on DockerHub?
- Remove HTTP/2 support until Go 1.6 HOT 2
- Non-integer input for size requests causes full image to be returned HOT 2
- Allow trailing slash on upload endpoint
- Incorrect Content-Type header prevents image resizing HOT 3
- Configurable logging port HOT 1
- Dead project? HOT 3
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 vip.