GithubHelp home page GithubHelp logo

bloomandwild / imagemagick-aws-lambda-2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from serverlesspub/imagemagick-aws-lambda-2

0.0 1.0 0.0 57 KB

ImageMagick for AWS Lambda 2 runtimes

Home Page: https://serverless.pub

License: Other

Makefile 41.93% JavaScript 58.07%

imagemagick-aws-lambda-2's Introduction

ImageMagick for AWS Lambda

Scripts to compile ImageMagick utilities for AWS Lambda instances powered by Amazon Linux 2.x, such as the nodejs10.x runtime, and the updated 2018.03 Amazon Linux 1 runtimes.

Amazon Linux 2 instances for Lambda no longer contain system utilities, so convert, mogrify and identify from the ImageMagick package are no longer available.

Usage

Absolutely the easiest way of using this is to pull it directly from the AWS Serverless Application repository into a CloudFormation/SAM application, or deploy directly from the Serverless Application Repository into your account, and then link as a layer.

For more information, check out the image-magick-lambda-layer application in the Serverless App Repository.

For manual deployments and custom builds, read below...

Prerequisites

  • Docker desktop
  • Unix Make environment
  • AWS command line utilities (just for deployment)

Compiling the code

  • start Docker services
  • make all

There are two make scripts in this project.

  • Makefile is intended to run on the build system, and just starts a Docker container matching the AWS Linux 2 environment for Lambda runtimes to compile ImageMagick using the second script.
  • Makefile_ImageMagick is the script that will run inside the container, and actually compile binaries.

The output will be in the result dir.

Configuring the build

By default, this compiles a version expecting to run as a Lambda layer from /opt. You can change the expected location by providing a TARGET variable when invoking make.

The default Docker image used is lambci/lambda-base-2:build. To use a different base, provide a DOCKER_IMAGE variable when invoking make.

Modify the versions of libraries or ImageMagick directly in Makefile_ImageMagick.

Experimenting

  • make bash to open an interactive shell with all the build directories mounted
  • make libs to make only the libraries, useful to test building additional libraries without building ImageMagick itself

Bundled libraries

This is not a full-blown ImageMagick setup you can expect on a regular Linux box, it's a slimmed down version to save space that works with the most common formats. You can add more formats by including another library into the build process in Makefile_ImageMagick.

These libraries are currently bundled:

  • libpng
  • libtiff
  • libjpeg
  • openjpeg2
  • libwebp

Deploying to AWS as a layer

Run the following command to deploy the compiled result as a layer in your AWS account.

make deploy DEPLOYMENT_BUCKET=<YOUR BUCKET NAME>

configuring the deployment

By default, this uses imagemagick-layer as the stack name. Provide a STACK_NAME variable when calling make deploy to use an alternative name.

example usage

An example project is in the example directory. It sets up two buckets, and listens to file uploads on the first bucket to convert and generate thumbnails, saving to the second bucket. You can deploy it from the root Makefile using:

make deploy-example DEPLOYMENT_BUCKET=<YOUR BUCKET NAME>

Info on scripts

For more information, check out:

Author

Gojko Adzic https://gojko.net

License

imagemagick-aws-lambda-2's People

Contributors

gojko avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.