2

I have a site that's live and getting new signups. I am running into an issue. Most of my users come from mobile, and when you upload a profile picture from mobile, then it's sideways. It's weird because it doesn't do that in the desktop version.

Is there a fix for this? I've been searching for hours and can't seem to find anything.

I would like to check for the image direction and save it so it appears upright.

EDIT: I am using lepozepo:s3 and uploading directly to amazon s3.

socialight
  • 487
  • 1
  • 5
  • 18

2 Answers2

0

Someone had a similar issue here: https://github.com/CollectionFS/Meteor-CollectionFS/issues/504

I'm assuming you're using CollectionFS since it's the most popular package to handle uploads and you haven't specified in your question.


You can correct this by adding a write transform to your storage adapter and using graphicsmagick's autoOrient option.

transformWrite: function(fileObj, readStream, writeStream) {
    gm(readStream, fileObj.name).autoOrient().stream().pipe(writeStream);
}

Additional reading: Images turning sideways/upside down after being uploaded via PhoneGap (iOS)

Community
  • 1
  • 1
Sergio Tapia
  • 9,173
  • 12
  • 35
  • 59
  • Hey Sergio, thanks for that. I'm only using lepozepo:s3, which I should have specified. I'm uploading directly to amazon s3. Will the function still work for that? – socialight Jul 18 '15 at 22:02
0

As far as I know lepozepo:s3 uploading files directly to amazon s3 which is good for large files but I wouldn't recommend to use it for images (avatars) uploads because you need to transform it and make sure that it's actually image and not broken (and nobody trying to hack you :D )

If you still want to use lepozepo:s3 then you should google canvas image manipulation on client side. There are some meteor packages that doing resize and crop on client so you will get the idea. Maybe with canvas you would be able to auto-orient images https://github.com/thinksoftware/meteor-image-resize-client

Also there are some AWS Lambda project that can help you with transforming images on s3 bucket but I don't know how to set it up.


Second option is to upload images through your meteor server that will transform it the way you want. I'm using CollectionFS package. It's not perfect but right now there is no ideal solution for file uploads in meteor.

I guess.. Ideally you need to run separate server for image uploads but who wants to deal with it :D

Dmitry
  • 168
  • 2
  • 9