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

caman-dist-only

v4.1.3

Published

Javascript (Ca)nvas (Man)ipulation for NodeJS and the browser - dist folder only to avoid dependency issues when browser only is desired

Downloads

236

Readme

About the Project

Build Status

The main focus of CamanJS is manipulating images using the HTML5 canvas and Javascript. It's a combination of a simple-to-use interface with advanced and efficient image/canvas editing techniques. It is also completely library independent and can be safely used next to jQuery, YUI, Scriptaculous, MooTools, etc.

CamanJS is very easy to extend with new filters and plugins, and it comes with a wide array of image editing functionality, which is only growing as the community makes more plugins. All features that are not a part of the core CamanJS library are in a separate plugins repository.

For more information, I highly recommend taking a look at the official website where there is more comprehensive documentation and interactive demos. You can also read the wiki for some basic information about the project and how to use it.

CamanJS is written in Coffeescript as of version 3.0. It works both in-browser and in NodeJS.

CamanJS is a project that I work on in purely my own spare time. If you would like to pitch in a beer or donate to say thanks, my Bitcoin address is: 1EVNQ7FiWDaqpfYXRLCtgMe5RBcz3kEuAG

Usage

Include one of the versions in the dist/ folder, then you can run:

Caman("#image-id", function () {
  this.brightness(10);
  this.contrast(20);
  this.render(function () {
    alert("Done!");
  });
});

Caman also supports modifying images via the data-caman HTML attribute. Simply separate each instruction with a space. Images with the data-caman attribute will automatically be modified at page load.

<img data-caman="saturation(-10) brightness(20) vignette('10%')" src="path/to/image.jpg">

HiDPI Support

Version 4 introduces better support for HiDPI (Retina) displays. It allows you to specify a higher resolution replacement using HTML data attributes. Keep in mind, however, that higher resolution images take longer to render.

HTML data attributes

  • data-caman-hidpi: URL to the high resolution replacement image
  • data-caman-hidpi-disabled: HiDPI support is enabled by default, so add this attribute if you wish to force disable it

Upgrading to Version 4

There is only 1 breaking change that occured with the version 4 release. When you initialize CamanJS with a canvas and an image, the parameter order has changed. It is now:

Caman("#canvas-id", "/path/to/image.png", function() {});

This is in order to be more consistent with initialization, such that the "initialization object" is always the first parameter. Update your code accordingly.

Development

If you are a developer who is contributing directly to the project, there are some tools to help you out.

Building

To install all dependencies required for development, run npm install -d.

Because all plugins are in a separate repository, make sure you run:

git submodule init && git submodule update

To build, simply run cake build. The resulting files will be placed in the dist/ folder. Plugins will be automatically discovered and added to caman.full.js after the core library. You can also auto-compile when a file changes by using cake watch.

If you add any files to the core library, you will need to add them to the coffeeFiles array in the Cakefile. The point of this is so that order is preserved when generating the file JS file. Plugins do not need to be added to the Cakefile.

You will probably want to generate documentation if you make any changes. In addition to the normal requirements, you will also need the Python library Pygments.

To generate the documentation, run cake docs.

CDN JS Hosting

CamanJS is hosted on CDN JS if you're looking for a CDN hosting solution. It is the full and minified version of the library, which means all plugins are included. Simply load CamanJS directly from this URL for usage on your site.

NodeJS Compatibility

CamanJS is fully compatible with NodeJS. The easiest way to install it is:

npm install caman

Saving from NodeJS

To save your modified image in NodeJS, simply call the save() function after rendering is finished by passing a callback function to render(). Trying to save before rendering is finished will cause issues.

Caman = require('caman').Caman;

Caman("./path/to/file.jpg", function () {
  this.brightness(40);
  this.render(function () {
    this.save("./output.png");
  });
});

Testing

Tests for CamanJS run both in NodeJS and the browser.

NodeJS

The NodeJS tests use mocha as the test runner. The simplest way to run the test suite is by running npm test.

Browser

The browser tests are run by Karma. It will start up Chrome, Firefox, and Safari (if running OSX) in the background. You can minimize each of these browsers if desired. It will automatically run tests after CamanJS is recompiled by the Cakefile as well.

You can run Karma by running karma start, or you can do a single run with the NodeJS tests by running npm test.