lib.utils.image
Tag 4
Image formatting service for files and AWS objects
  Published by utils on May 31st 2017, 11:39 PM
  # Image Manipulation Service 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 ``` const fs = require('fs'); const lib = require('lib'); const file = fs.readFileSync('./image-file.png'); lib.utils.image({ file: file, options: { resize: [300, 200], flip: true } }, (err, convertedImage) => { // do things with convertedImage }); ``` ### AWS S3 ``` 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.image({ key: 's3-file-path/file.png', options: { resize: [200, 300], charcoal: 1 } }, (err, convertedImage) => { // do things with convertedImage }); ``` ## Supported Options 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.image({ file: file, options: { 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&...` ## Base64 If you want the response to be in `base64`, you can pass in `base64: true` as an argument. ``` lib.utils.image({ file: file, options: { resize: [320, 320] }, base64: true }, ...) ```
# Image Manipulation Service 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 ``` const fs = require('fs'); const lib = require('lib'); const file = fs.readFileSync('./image-file.png'); lib.utils.image({ file: file, options: { resize: [300, 200], flip: true } }, (err, convertedImage) => { // do things with convertedImage }); ``` ### AWS S3 ``` 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.image({ key: 's3-file-path/file.png', options: { resize: [200, 300], charcoal: 1 } }, (err, convertedImage) => { // do things with convertedImage }); ``` ## Supported Options 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.image({ file: file, options: { 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&...` ## Base64 If you want the response to be in `base64`, you can pass in `base64: true` as an argument. ``` lib.utils.image({ file: file, options: { resize: [320, 320] }, base64: true }, ...) ```
  info
context
enabled
bg
info
pricing
free
rate limits
  parameters (click to modify)
{string}
key
= ""
S3 Object Key (required if no file is provided)
{buffer}
file
= null
File buffer (required if no key and AWS credentials provided)
{object}
options
= {}
Options ot pass on to imageMagick
{boolean}
base64
= false
If data should be returned in base64
  code