npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rsvg-convert-aws-lambda-binary

v1.0.2

Published

A statically linked rsvg-convert binary utility from the librsvg Linux package, allowing you to render SVG images to PDF and PNG on AWS Lambda using Cairo.

Downloads

18

Readme

Static rsvg-convert binary for AWS Lambda

A statically linked rsvg-convert binary utility from the librsvg Linux package, allowing you to render SVG images to PDF and PNG on AWS Lambda using Cairo.

Why?

The standard AWS Lambda Linux VM comes with imagemagick, but compiled without SVG support. In order to process SVG images, you either need to add SVG support to ImageMagick or use a custom tool. RSVG+Cairo is the best back-end for SVG processing in imagemagick anyway, so this binary gives you direct access to that toolkit.

Download the binary

Grab the binary from the vendor directory

Usage:
  rsvg-convert [OPTION…] [FILE...] - SVG Converter

Help Options:
  -?, --help                                                  Show help options

Application Options:
  -d, --dpi-x=<float>                                         pixels per inch [optional; defaults to 90dpi]
  -p, --dpi-y=<float>                                         pixels per inch [optional; defaults to 90dpi]
  -x, --x-zoom=<float>                                        x zoom factor [optional; defaults to 1.0]
  -y, --y-zoom=<float>                                        y zoom factor [optional; defaults to 1.0]
  -z, --zoom=<float>                                          zoom factor [optional; defaults to 1.0]
  -w, --width=<int>                                           width [optional; defaults to the SVG's width]
  -h, --height=<int>                                          height [optional; defaults to the SVG's height]
  -f, --format=[png, pdf, ps, svg]                            save format [optional; defaults to 'png']
  -o, --output                                                output filename [optional; defaults to stdout]
  -a, --keep-aspect-ratio                                     whether to preserve the aspect ratio [optional; defaults to FALSE]
  -b, --background-color=[black, white, #abccee, #aaa...]     set the background color [optional; defaults to None]
  -v, --version                                               show version information
  --base-uri                                                  base uri

Usage from Node.js

Check out the SVG to PDF Example Project.

Using custom fonts

RSVG uses Pango, and Pango uses Font-Config to load fonts. To use a custom set of fonts, you'll need to provide a trivial fonts.conf file somewhere and point to it using the FONTCONFIG_PATH environment variable. For example, put the fonts into the fonts subdirectory of your application, then add this file to your application root dir as fonts.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>./fonts/</dir>
  <cachedir>/tmp/fonts-cache/</cachedir>
  <config></config>
</fontconfig>

Then run FONTCONFIG_PATH=<APP-ROOT> <RSVG_DIR>/rsvg-convert input.svg -o output.svg

Versions

Compiled with AMI ami-60b6c60a, 29 October 2016, with the following library versions:

  • cairo: 1.12.14
  • pango: 1.28.4
  • libcroco: 0.6.8
  • gdk-pixbuf: 2.28.2
  • librsvg: 2.26.3

These are all a bit old, but are compatible with the other libraries available through YUM for the Amazon Linux instance. To get a more recent version built, modify compile-static.sh to include the appropriate versions of dependencies.

Creating a fresh compilation

  1. Create an AMI
  2. ssh to the AMI as ec2-user
  3. on the VM, run system_init.sh
  4. on the VM, run compile-static.sh

Testing on a (non-Lambda) AWS Linux VM

The binary will work on a plain-vanilla AWS Linux VM, but needs some additional packages (these are already available on the VM used for Lambda functions).

sudo yum install cairo libtiff -y

Copyright and license

GNU GENERAL PUBLIC LICENSE. Copyright (C) 1989, 1991 Free Software Foundation, Inc. Original LibRSVG license.