Skip to content

Docker based service for uploading and transforming images on the fly ๐Ÿฆ‹

License

Notifications You must be signed in to change notification settings

paralect/img-fly

Repository files navigation

Img Fly

Stack

All Contributors license PRs Welcome Build Status David Dependancy Status

Watch on GitHub Star on GitHub Follow Tweet

Docker based service for uploading and transforming images on the fly ๐Ÿฆ‹. Based on native, ultra fast Sharp and Amazon S3.

Features

  • ๐Ÿ”ฅ๏ธ Transform images on the fly Upload image and apply transformation by adding them to the url. Similar to Cloudinary.
  • ๐Ÿ˜ Resize, Crop, Face detection and other image transformations. Based on Sharp
  • ๐Ÿ™€ Amazon S3 as file storage we store original uploads and all transformations over to your S3 bucket.
  • ๐Ÿค— Upload directly from client app. .
  • ๏ธโšก๏ธ Easy to use Img Fly is a Node.JS based microservice, shipped in Docker container.
  • ๐Ÿ’ฐ Automated S3 storage cleanup. We cleanup your S3 bucket if file isn't accessed for over 30 days. ImgFly saves your money. (planned)
  • ๐Ÿ‘ฎโ€โ™‚๏ธ Secure โ€” we keep all uploads and file access secure by verifying md5(resourceId,imgFlySecretKey). (planned)

Getting Started

Play around

  1. Clone this repo
  2. Create .env file with Amazon s3 credentials (see .env.example).
  3. Start a project using ./bin/start.sh.
  4. Navigate to the http://localhost:3002/ and upload image file.
  5. Click on the transformation link and play around with url params.

Extract + Resize example: http://localhost:3001/5ac0bb5fab7ce4028e879d03/extract-left_0,top_30,width_400,height_300+resize-width_300/nice_file_name.png

Add ImgFly to your project

ImgFly shipped as Docker container. If you already using docker-compose for your project it won't take more than 5 minutes to install and start using ImgFly.

You'll need to add following to your docker-compose file. Full installation and usage guide

img-fly:
    image: paralect/img-fly:v0.2.2
    ports:
      - "3003:3001"
    environment:
      NODE_ENV: "production"
      IMG_FLY_AWS_SECRET_KEY: "YOUR AWS SECRET"
      IMG_FLY_AWS_ACCESS_KEY: "YOUR AWS ACCESS KEY"
      IMG_FLY_AWS_S3_REGION: "YOUR AWS REGION"
      IMG_FLY_AWS_S3_BUCKET: "YOUR BUCKET NAME"
      IMG_FLY_MONGO_CONNECTION: "mongodb://mongo:27017/img-fly-dev"
      IMG_FLY_MONGO_COLLECTION: "img-fly_files"
      IMG_FLY_API_URL: "http://localhost:3003"
      IMG_FLY_DEBUG: "true"

Supported transformations

  1. Extract
  2. Resize
  3. Extract
  4. Blur
  5. toFormat
  6. Grayscale filter

All transformations (code)

Feel free to submit PR's with more transformations. You'll need to implement a function which maps query params to the sharp function params.

Building transfomration query

We use following rules to form query params.

  1. + is used to combine multiple transformations.
  2. - is used as separator between transformation name and params.
  3. _ is used to separate param name and param value;

Example of applying extract & resize transformations: extract-left_0,top_30,width_400,height_300+resize-width_300

Example of resize and crop: resize-width_300,height_300+crop-strategy_attention

Demo

N/A

Change Log

This project adheres to Semantic Versioning. Every release is documented on the Github Releases page.

License

Ship is released under the MIT License.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Contributors

Thanks goes to these wonderful people (emoji key):


Evgeny Zhivitsa

๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐Ÿ‘€ โš ๏ธ

Ihar

๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐Ÿ‘€

Andrew Orsich

๐Ÿ’ป ๐Ÿ“– ๐Ÿค”

This project follows the all-contributors specification. Contributions of any kind welcome!