All Projects â†’ dwyl â†’ Image Uploads

dwyl / Image Uploads

🌅 Effortless Image Uploads

Programming Languages

javascript
184084 projects - #8 most used programming language

A solution to uploading photos with AWS Lambda

Why?

Helping people communicate in pictures makes their lives better.

What?

A simple image uploader module that can be included within your project.

It will:

  • Upload imagess (to S3 and Google drive/photos) effortlessly
  • Use ImageMagic to automatically re-size & optimise the image for mobile devices
  • Return a list of the images that were uploaded to S3 for use in other objects.

Image Re-Sizing using gm

gm depends on ImageMagick. On a Mac you will need Homebrew to install ImageMagic (the easy & fast way.)

brew install imagemagick

If you want to enable WebP support for your images, you must include the following flag in your installation command:

brew install imagemagick --with-webp

Usage: https://www.npmjs.com/package/gm

Image Rotation

We started using this code in staging today and users started uploading images imediately.

"Its faster than Instagram!" ~ A User

Was a user comment that delighted us.

However they uploaded images from their iDevices which were not in the correct orientation...

So we need to add rotation.

Assumptions

Aproximately 90% of people are right-handed.

iphone landscape right-handed

Therefore we need to rotate images 90 degrees clockwise.

We'll be using gm for our image rotation.

Understanding JPEG Exif Orientation

For convenience, here is what the letter F would look like if it were tagged correctly and displayed by a program that ignores the orientation tag (thus showing the stored image):

  1          2         3        4         5                 6           7            8

888888    888888        88    88        8888888888    88                   88   8888888888
88            88        88    88        88  88        88  88           88  88       88  88
8888        8888      8888    8888      88            8888888888   8888888888           88
88            88        88    88
88            88    888888    888888

Temporary Folder / Files

Usage: https://github.com/raszi/node-tmp
Latest version: https://www.npmjs.org/package/tmp

Research (way more detail than you'll ever need)

Image-upload-as-a-Service Provider

How are others solving the problem?

There was a suggestion to use Meteor CollectionFS: https://github.com/CollectionFS/Meteor-CollectionFS to upload/store images. This is a terrible idea because the file gets stored in MongoDB! Not only is MongoDB storage considerably more expensive, its also slower than a CDN!! (If you know why this is a good idea, please tell me!)

Avoid Filename Collisions with Hashes

All the big players are storing files with generated names (instead of using the files' original name such as "photo1.jpg" thus avoiding name collisions) e.g:

Google is maintaining the file name and storing it in a folder:

Should we maintain the filename? I tend to re-name all the photos I want to be able find later. So does giving these hash.jpg on our system loose some valuable information...? (feedback please...!)

Helpful Links

Troubleshooting

History

I've partially "solved" this problem before:

I need to re-visit these and get them working together (with tests :-)

Popular Image Web/Mobile Sites/Apps

The more successful image apps on the web/mobile:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].