Skip to content

Convert SVG images easily to PNG and JPG using AWS Lambda.

License

Notifications You must be signed in to change notification settings

bubblydoo/librsvg-lambda-layer

Repository files navigation

LibRSVG for AWS Lambda

Releases Build Docker Layer

Scripts to statically compile LibRSVG for AWS Lambda instances powered by Amazon Linux 2.x.

Usage

The rsvg binary will be in /opt/bin/rsvg-convert after linking the layer to a Lambda function.

Download

The Lambda Layer ZIP can be found in Releases.

Prerequisites

  • Docker
  • AWS command line utilities (just for deployment)

Compilation and deployment

  • Clone the repository
git clone github.com/bubblydoo/librsvg-lambda-layer
cd librsvg-lambda-layer
  • Start Docker services and build image (this might take a while)
docker build . --target librsvg-layer -t amazon-linux-librsvg-layer
# docker build . --target librsvg -t amazon-linux-librsvg
# docker build . --target builder -t amazon-linux-librsvg-builder
  • Copy zip to ./dist
docker run -v "$PWD/dist":/dist amazon-linux-librsvg-layer
  • Inspect layer content
unzip -l dist/librsvg-layer.zip
  • Deploy to AWS
aws lambda publish-layer-version \
  --layer-name rsvg \
  --description "Librsvg layer" \
  --license-info "MIT License" \
  --zip-file fileb://dist/librsvg-layer.zip \
  --compatible-runtimes nodejs12.x

Compiled info

rsvg-convert: version Version

Caveats

  • Images with xlink:href="file:// do not load properly. You can inline the files as a data:// uri as a workaround.
  • Only jpeg and png builtin loaders are enabled (for usage with data://), but more can be enabled in Dockerfile

More information

For more information, check out:

Author

Hans Otto Wirtz https://github.com/hansottowirtz Gojko Adzic https://gojko.net

License