笔记 - 基于 Node Canvas 的占位图生成器



Image Placeholder Tool

Introduction

Repository

https://github.com/songxc/image-proc-cairo

Dependencies

Demo

Visit after start service.

API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
url: http://127.0.0.1:3000/blur
params:
{String} callback: callback function name. default: empty;
{String} src: input image url;
{Integer} size: output image size. default: 30, maximum: 100;
{Integer} radius: output image blur strength, bigger leads to more blurry. default: 1, maximum: 20;
result:
{Boolean} success: status;
{String} message: status message;
{String} errMessage: error message;
{String} src: input image url;
{String} size: output image size;
{String} radius: output image blur strength;
{String} imgDataURL: output image data url (Base64);

Deploy

Initialize

  1. expressnpm install express --save
  2. express-generatornpm install express-generator -g
  3. yeomannpm install yo -g
  4. yo express

Update

  1. Update Homebrewbrew update
  2. Update Software:brew upgrade
  3. Install wget:brew install wget

Install

  1. Cairobrew install pkg-config cairo libpng jpeg giflib(For Mac)
  2. Canvasnpm install canvas
  3. nodemonnpm install nodemon -g
  4. npm install

Start

nodemon ./bin/www

Reference

Express
Which library should I use for server-side image manipulation on Node.JS?
How do I interact with this object in a node.js stream?