@ligadigital/image-resizer
Resize images on the fly
Last updated 2 years ago by josa .
MIT · Original npm · Tarball · package.json
$ cnpm install @ligadigital/image-resizer 
SYNC missed versions from official npm registry.

Image Resizer

Build Status node NpmLicense npm (scoped)

Usage

GET /:mode/:size/:path

Modes

Must be one of the following:

  • resize
  • crop
  • resizefit
  • resizefitgray
  • shrink

Size

Must be in one of the following formats:

  • 100x100 (width and height)
  • 100x (width only)
  • x100 (height only)

Examples

GET /crop/100x100/example.org/my-image.jpeg

S3

If a S3 bucket is configured the process works like this:

  • Request app requests image from S3 bucket
  • If the image does not exist, S3 redirects to the image-resizer
    • ln-image-resizer resizes the image un puts it on S3
    • ln-image-resizer redirects back to S3
  • If the image exist, S3 serves the image

Example s3 Routing rule

<RoutingRules>
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals>image-resizer/</KeyPrefixEquals>
      <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
    </Condition>
    <Redirect>
      <Protocol>https</Protocol>
      <HostName>example.org</HostName>
      <ReplaceKeyPrefixWith>image-resizer/</ReplaceKeyPrefixWith>
      <HttpRedirectCode>302</HttpRedirectCode>
    </Redirect>
  </RoutingRule>
</RoutingRules>

Configureation

All configuration is done via enviroment variables:

  • S3_BUCKET (e.g. ligacloud-ligaos-test-static)
  • S3_PATH" (e.g. ln-image-resizer)
  • S3_URL (e.g. http://ligacloud-ligaos-test-static.s3-website.eu-central-1.amazonaws.com)
  • S3_ACCESS_KEY_ID
  • S3_SECRET_ACCESS_KEY

Dependencies

On Mac:

brew install imagemagick
brew install graphicsmagick
brew install gifsicle

TODOs

  • [ ] Make tmp/ dir configurable
  • [ ] Docker container
  • [ ] Better documentation
  • [ ] Drop node 4 support

Current Tags

  • 0.2.1                                ...           latest (2 years ago)

3 Versions

  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 3
Last Month 4
Dependencies (13)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |