Code Monkey home page Code Monkey logo

canvas2image's Introduction

Canvas to image

English Documentation

一个用于保存和转换 canvas 到图片的工具(下载时有文件扩展名).

Cloned from https://github.com/hongru/canvas2image.

1. 加载资源

const Canvas2Image = require('@senntyou/canvas2image');

Canvas2Image.doSomething().

2. 怎样使用

Canvas2Image.saveAsImage(canvas, width, height, type);
Canvas2Image.saveAsPNG(canvas, width, height);
Canvas2Image.saveAsJPEG(canvas, width, height);
Canvas2Image.saveAsGIF(canvas, width, height);
Canvas2Image.saveAsBMP(canvas, width, height);

Canvas2Image.convertToImage(canvas, width, height, type);
Canvas2Image.convertToPNG(canvas, width, height);
Canvas2Image.convertToJPEG(canvas, width, height);
Canvas2Image.convertToGIF(canvas, width, height);
Canvas2Image.convertToBMP(canvas, width, height);

2.1 saveAsImage

保存 canvas 为一张图片.

Canvas2Image.saveAsImage(canvas, width, height, type);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.
  • type: png|jpeg|gif|bmp.

2.2 saveAsPNG

保存 canvas 为一张 png 图片.

Canvas2Image.saveAsPNG(canvas, width, height);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.

2.3 saveAsJPEG

保存 canvas 为一张 jpeg 图片.

Canvas2Image.saveAsJPEG(canvas, width, height);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.

2.4 saveAsGIF

保存 canvas 为一张 gif 图片.

Canvas2Image.saveAsGIF(canvas, width, height);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.

2.5 saveAsBMP

保存 canvas 为一张 bmp 图片.

Canvas2Image.saveAsBMP(canvas, width, height);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.

2.6 convertToImage

保存 canvas 为一个 img Element.

let img = Canvas2Image.convertToImage(canvas, width, height, type);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.
  • type: png|jpeg|gif|bmp.

2.7 convertToPNG

保存 canvas 为一个 png 图片的 img Element.

let img = Canvas2Image.convertToPNG(canvas, width, height);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.

2.8 convertToJPEG

保存 canvas 为一个 jpeg 图片的 img Element.

let img = Canvas2Image.convertToJPEG(canvas, width, height);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.

2.9 convertToGIF

保存 canvas 为一个 gif 图片的 img Element.

let img = Canvas2Image.convertToGIF(canvas, width, height);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.

2.10 convertToBMP

保存 canvas 为一个 bmp 图片的 img Element.

let img = Canvas2Image.convertToBMP(canvas, width, height);
  • canvas: Canvas 实例.
  • width: Image 宽度.
  • height: Image 高度.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.