furagu / easy-gd

A simplified Node.js wrapper around GD image manipulation library with extra features making your life easier.
MIT License
25 stars 14 forks source link

Disabled automatic rotation of the image on open #2

Closed SergeMv closed 9 years ago

SergeMv commented 11 years ago

It is made optional. I know it looks ugly as the callback is not the last argument to createFromPtr(), but I couldn't make an optional parameter to be not the last.

furagu commented 11 years ago

Thanks for request. Being able to switch autorotation off seems to be useful sometimes, so I made createFromPtr accept options, particularly the autorotate one.

But I think the autorotation feature should be turned on by default, because most of the time what you want is to open that image correctly, not messing around with Exif or anything else.

So I made it this way:

gd.createFromPtr(buffer, callback) // rotates
gd.createFromPtr(buffer, {autorotate: false}, callback) // does not rotate

You can get the latest version from master or install/update it with npm.

furagu commented 11 years ago

SergeMv, any thoughts?

Suor commented 11 years ago

Same option for .createFrom() would be nice )

furagu commented 11 years ago

Well, I thought about adding this option to createFrom, but found it hardly applicable to practical use. See, if you tell it "Don't do anything with Exif, plz", you should handle Exif yourself or you get badly rotated images. GD does not tell you about Exif, it just returns the image which has all the Exif data vanished. So you need to open the file yourself, read the data into some buffer and then have some processing of Exif within than buffer. But why read the file twice? Read it once and do whatever you want :)

Suor commented 11 years ago

There are several ways your reasoning may not apply:

  1. A guy may already know how he gonna rotate it.
  2. A guy may not care.
  3. Information is lost only if image is resaved. A guy may be not going to.

And if all this does not convince you, you can add it just for consistency. And for less questions/issues in future.

furagu commented 11 years ago

Recently it came to my mind that having parsed Exif data right in the gd.Image could be very handy (one could determine the geographical position for example). And with that extension autorotate: false would be natural to have in createFrom too.