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

fireball

v1.0.0

Published

A very simple image host

Downloads

23

Readme

fireball

A very simple image hosting library

  • Serve images (originals and resized to preconfigured sizes) from configurable directory
  • Uses hapi
  • Requires either GraphicsMagick or ImageMagick. Please see gm docs for more info
  • Patterned after bumble

Add the module to your app

npm install fireball
var Hapi = require('hapi');
var config = require('./fireballConfig.json');


var server = new Hapi.Server('0.0.0.0', 3000 || process.env.PORT);

server.pack.require({'fireball': config}, function (err) {
    if (err) throw err;
    server.start(function () {
        server.log(['info', 'fireball], 'fireball running on the year' + server.info.port);
    });
});

Set your defaults in fireballConfig.json

{
    "cache": 3600000,
    "baseURL": "/url/to/images",
    "imageDir": "path/to/images",
    "saveDir": "path/to/save/resized/images",
    "processing": [
        {
            "suffix": "s",
            "action": "resize",
            "params": [256, null, ">"]
        },
        {
            "suffix": "m",
            "action": "resize",
            "params": [512, null, ">"]
        },
        {
            "suffix": "l",
            "action": "resize",
            "params": [1024, null, ">"]
        }
    ]
}

cache: (integer, optional, default=3600000 (one hour)) Expiration time in milliseconds to send to the browser on request. Set to 0 to disable browser-cache headers.

baseURL: (string, optional, default=/fireball/) where the images will be served from

imageDir: (string, optional, default=images) local directory to look in for images. Subdirectories here will translate to the url of the images.

saveDir: (string, optional, default=fireballImages) where to save the processed images, will be created if missing.

processing: (object, optional, default=see below) defines the processing to do to images, key names here are added to the url of the original image. Currently only resize is supported.

reprocess: (boolean, optional, default=false) whether or not to reprocess all files in imageDir on startup regardless of if they have processed results in saveDir

Default processing

By default fireball will process images into three versions: s, m, and l with scaled widths of 256, 512, and 1024px respectively. If the original image is smaller than the processed version would be the original is kept.

Example urls:

Let's say you set baseURL to /pics and that you put an image named mycat.jpg in the configured imageDir. Given the above example, Fireball would then make that photo available at the following urls (assuming you were running off of localhost):

http://localhost/pics/mycat.jpg
http://localhost/pics/mycat-s.jpg
http://localhost/pics/mycat-m.jpg
http://localhost/pics/mycat-l.jpg

These would be the original, 256px wide, 512px wide, and 1024px wide versions of that image. Fireball will not increase the size of an image, if the resize is greater than the original, the original is used.

Caching

When reprocess is false (which it is by default), if a suffix has alread ran through a given processing action, it will not run again. This is great for startup times, but it means that if you change a processing rule for a given suffix, you will need to remove all the files from the saveDir for that suffix.