Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
.autoOrient() doesn't work with .thumb() #99
I need to create thumbnails of images that may be EXIF-rotated. I tried sticking an .autoOrient() before the .thumb() call like this:
When I do that, the output image re-orients correctly, but now the thumbnail is squashed-to-square instead of cropped-to-square. Is this a bug or am I missing something?
Not sure, both thumb and autoOrient are sugar and involve several calls to graphicsmagick which may not play perfectly well together. It should be easy to track down what this issue is by just executing the code inline and playing with the options that are used.
Let me know what you find out.
autoOrient doesn't play well with resize(), either. To get it to do both, I have to do an orient, and then a write, like this: (coffeescript)
img = im(path).autoOrient().write path, (err) -> if err return console.log err img = im(path) img.resize(200, 200).write newPath, (err) -> if err return console.log err # success code
I wonder if this is only an issue because both me and OP are using the ImageMagick subClass...?
The problem appears to be that autoOrient() somehow clears out the options set by thumb(). If I run thumb() alone, then this is the arguments that get used:
"-quality" "80" "public/images/7b96fdc5f296fedecdb1bdb9c191bb25/image.jpg" "-scale" "133x100" "-crop" "100x100+16.5+0" "+profile" ""*"" "public/images/7b96fdc5f296fedecdb1bdb9c191bb25/image_100x100.jpeg"
However, if I chain in an autoOrient().thumb(), and then hold my phone in such a way that no rotation is necessary, then these arguments get used:
convert "public/images/a7728a4ca56ad238721459961fc36f45/image.jpg" "public/images/a7728a4ca56ad238721459961fc36f45/image_100x100.jpeg"
If I chain autoOrient().thumb(), and hold my phone at a 90 degree angle, these arguments get used:
"public/images/2c263cc7fc55edee15e7e3ae2e66649c/image.jpg" "-rotate" "90" "-page" "+0+0" "+profile" ""*"" "public/images/2c263cc7fc55edee15e7e3ae2e66649c/image_100x100.jpeg"
Again, these arguments are ones set by autoOrient(), with none of the options set by thumb() making it through to the end.
added a commit
Dec 6, 2012
referenced this issue
Dec 6, 2012
this is still an issue for me. i'm on 1.8.1 and the arguments are no longer being lost the but the final generated command does not produce the intended result.
i have some coffescript that does this:
with a portrait image and
the final image is not cropped, however. removing the "-scale" option fixes the issue. this command produces the proper thumb:
i'm not sure why the "-scale" option is only an issue when auto-orienting but that's the behavior i'm observing.