Code Monkey home page Code Monkey logo

rsvg-convert-aws-lambda-binary's Introduction

RSVG-Convert (LibRSVG) for AWS Lambda

Scripts to compile LibRSVG 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.

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.

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

For more information, check out the rsvg-convert-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 Rsvg using the second script.
  • Makefile_Rsvg 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 librsvg directly in Makefile_Rsvg.

Experimenting

  • make bash to open an interactive shell with all the build directories mounted

Compiled info

rsvg-convert version 2.26.3

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 rsvg-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 PDF files from SVG images. You can deploy it from the root Makefile using:

make deploy-example DEPLOYMENT_BUCKET=<YOUR BUCKET NAME>

For more information, check out:

Author

Gojko Adzic https://gojko.net

License

rsvg-convert-aws-lambda-binary's People

Contributors

gojko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rsvg-convert-aws-lambda-binary's Issues

Not rendering SVG Pattern elements

I have an SVG file that contains a <rect> element with a <pattern> as fill. When I convert this file to PNG or PDF, this rect is not rendered.

Follow the SVG code:

<svg viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="800" height="800"> <rect width="100%" height="100%" fill="url(#Svgjs1018)" x="0" y="0" class=""></rect> <pattern x="0" y="0" width="32" height="26" patternUnits="userSpaceOnUse" id="Svgjs1018"> <g> <rect x="0" class="pattern-background-rect" fill="#63c6ff" width="32" height="26"></rect> <g fill="#000000" fill-opacity="0.18"> <path d="M12,0h2v4c0,3.9-3.1,7-7,7c-3.9,0-7-3.1-7-7V0h2v4c0,2.8,2.2,5,5,5c2.8,0,5-2.2,5-5V0z M7,13c-3.9,0-7,3.1-7,7v6h2v-6 c0-2.8,2.2-5,5-5c2.8,0,5,2.2,5,5v6h2v-6C14,16.1,10.9,13,7,13z M30,7v10c0,3.9-3.1,7-7,7c-3.9,0-7-3.1-7-7V7c0-3.9,3.1-7,7-7 C26.9,0,30,3.1,30,7z M28,7c0-2.8-2.2-5-5-5c-2.8,0-5,2.2-5,5v10c0,2.8,2.2,5,5,5c2.8,0,5-2.2,5-5V7z"></path> </g> </g> </pattern> </svg>

Pango warning when converting SVG with text to PNG

I'm getting the following error when I try to convert an SVG with text to a PNG:

(rsvg-convert:26874): Pango-WARNING **: failed to choose a font, expect ugly output. engine-type='PangoRenderFc', script='latin'

The resulting output has unreadable text.

Input SVG:

<svg xmlns="http://www.w3.org/2000/svg"
     width="500" height="40" viewBox="0 0 500 40">

  <text x="0" y="35" font-size="35">
    Hello, out there
  </text>
</svg>

Output PNG:
output

However the SVG export works perfectly if there is no text in the SVG.

I am running on an EC2 instance and I get the same problem with the provided binary in the vendor folder and after I compile the binary with compile-static.sh.

This is not a problem when I convert the same image with the rsvg pulled from my package manager in Ubuntu (rsvg-convert version 2.40.13).

Any ideas?

Error spawn convert ENOENT

I just create lambda function and used this layer. But when I add font for text in image, I get an error:
Runtime of lambda function is 10.x. If Runtime is 8.10 it works fine.

{ "errorType": "Error", "errorMessage": "spawn convert ENOENT", "trace": [ "Error: spawn convert ENOENT", " at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)", " at onErrorNT (internal/child_process.js:415:16)", " at process._tickCallback (internal/process/next_tick.js:63:19)" ] }

My params: -size,863x875,xc:transparent,(,-fill,#231f20,-size,391.8412x245.1814,xc:transparent,-font,/tmp/fonts/Archer-Bold.ttf,-pointsize,22.152,-stroke,none,-draw,gravity center kerning 0 text 0,0 "I love you so",-background,none,-rotate,0.00,),-geometry,+228.4788+551.5006,-composite,/tmp/images/gexqcZl7zU.png

Can you detect for me about to solve it.

/opt/bin/rsvg-convert: /lib64/libc.so.6: version `GLIBC_2.25' not found

Hi,
I was trying to use rsvg-convert as a lambda layer, but got the following error when trying to invoke it:

/opt/bin/rsvg-convert: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by /opt/bin/rsvg-convert)

I am using a Python runtime, but I assumed this shouldn't matter since I'm just directly executing the binary located at /opt/bin/rsvg-convert.

I installed it by using deploy from the serverless repo at https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:145266761615:applications~rsvg-convert-lambda-layer
I thought this would allow me to just execute it, but clearly it is missing a library where ever it is running. How do I make sure the right glibc is available? Do I have to rebuild it and relink and repackage it somehow?

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.