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

image-proxy

v0.0.7

Published

A simple image proxy optimized for headshots

Downloads

20

Readme

Image Proxy

NPM version Build Status Dependency Status Coverage Status

A simple Express app for proxying and manipulating images, specifically headshots.

The code is just over 100 lines, making it easy to tailor to your needs.

Getting Started

npm install
npm start
curl -I http://localhost:5000/http%3A%2F%2F1.gravatar.com%2Favatar%2F60f641dfbb4215f1f6d6c059eebf1848/240/80.jpg

The URL structure is /:url/:width/:height.:extension?. The :url parameter must be escaped/encoded. If the remote image's width or height is greater than the given :width or :height, it will be resized, maintaining aspect ratio, and cropped. If smaller, it will be padded with white pixels. If an optional :extension parameter is provided, the image will be transcoded to the corresponding file format. The equivalent ImageMagick command for the example URL above is:

convert input.jpg -thumbnail 240x80^> -gravity center -extent 240x80 output.jpg

The Cache-Control header sets a max-age of one year.

Features

Image proxy:

  • Supports HTTP and HTTPS
  • Follows 301 and 302 redirects
  • Sets a maximum timeout for the remote server
  • Handles complex MIME types like image/jpeg; charset=utf-8
  • Optional whitelisting using regular expressions

Image manipulation:

  • Accepts a custom width and height, up to 1000x1000
  • Resizes, centers and crops the image
  • Optionally transcodes to another file format

HTTP server:

  • No query string parameters (preferred by CloudFront)
  • Adds a Cache-Control header

If you need more features, see node-imageable and node-imageable-server.

Environment variables

  • DELAY: The timeout delay in milliseconds, after which the proxy will respond with a HTTP 504 Gateway Timeout server error. Default: 5000
  • WHITELIST: A comma-separated list of domains to whitelist, e.g. .gov,facebook.com, which will be transformed into the regular expressions /\.gov$/ and /facebook\.com$/.
  • PORT: If running the server, changes the port on which it listens. Default: 5000

Deployment

Heroku

git clone https://github.com/jpmckinney/image-proxy.git
heroku create
heroku config:set NODE_ENV=production
git push heroku master
heroku apps:open

AWS CloudFront

Create a distribution and set the "Origin Domain Name" to the domain name of your Heroku app.

Testing

npm test

Acknowledgements

This project is inspired by node-connect-image-proxy.

Copyright (c) 2013 James McKinney, released under the MIT license