utils/formatImage
Image formating service
  README.md
# Image Manipulation Service # DEPRECATED: Please use [utils/image](https://stdlib.com/utils/image) instead. This service lets you manipulate images that you upload or already have on [Amazon S3](https://aws.amazon.com/s3/) with ImageMagic and can be used at scale, right away. ## Usage ### File Upload #### Shell ``` lib -f ./image-file.png --resize 200,300 --flip > output.png ``` #### Programmatic ``` const fs = require('fs'); const lib = require('lib'); const file = fs.readFileSync('./image-file.png'); lib.utils.formatImage(file, { resize: [300, 200], flip: true }, (err, convertedImage) => { }); ``` ### AWS S3 #### Shell ``` lib utils.formatImage --key aws-file-key/path.png --resize 200,300 --s3AccessKeyId S3_ACCESS_KEY_ID --s3SecretAccessKey S3_SECRET_ACCESS_KEY --s3Bucket S3_BUCKET --s3Region S3_REGION ``` #### Programmatic ``` const lib = require('lib'); const utils = lib.utils({ S3_ACCESS_KEY_ID: 'S3_ACCESS_KEY', S3_SECRET_ACCESS_KEY: 'S3_SECRET_ACCESS_KEY', S3_BUCKET: 'S3_BUCKET', S3_REGION: 'S3_REGION', }); utils.formatImage({ key: 's3-file-path/file.png', resize: [200, 300], charcoal: 1 }, (err, convertedImage) => { }); ``` ## Supported Functions The service supports all the manipulation functionality on the GraphicsMagick module, which are [listed here](http://aheckmann.github.io/gm/docs.html#manipulation). For functions that have multiple arguments, pass in an array. For example, the resize function accepts two arguments: ``` ... lib.utils.formatImage(file, { resize: [320, 320] }, ...) ``` In the case that you might be using the function using HTTP (Note: not recommended in production!) then you can pass in the arguments separated by a comma: `https://utils.stdlib.com/image?resize=300,300&...` ## Format You can pass in a `format` keyword argument to change the default `PNG` format to `JPG`, `GIF`, or `BMP`. If you want the response to be in `base64`, you can pass in `base64: true` as a keyword argument.
  Published by jacoblee on Wednesday, March 8th, 2017, 9:24:39 PM
This service has 1 function
  main default function
  Pricing
 per request
 per second
  Format Images (by uploading a file or from AWS)
   Arguments
[0] file – ignored if AWS credentials are given. Credentials can be set via S3_ACCESS_KEY_ID S3_SECRET_ACCESS_KEY S3_REGION and S3_BUCKET keys.
   Keyword Arguments
a comprehensive list can be found here: https://github.com/aheckmann/gm#methods under 'manipulation'
base64 set to true if you'd like to receive the result in base64 instead of binary format.
format Image format. Default is PNG. Allowed are: PNG, JPG, GIF, BMP.
key AWS object key – ignored if no AWS credentials are provided.