GithubHelp home page GithubHelp logo

archiewx / doimg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juneandgreen/doimg

0.0 2.0 0.0 797 KB

纯js实现的简单图形解码库(未完全完成)

License: MIT License

JavaScript 4.18% HTML 95.82%

doimg's Introduction

doimg

一个简单的图片解码工具

png解码器

const Png = require('doimg').Png;

let png = new Png(buffer);

console.log(png.width); // 图像宽度
console.log(png.height); // 图像高度
console.log(png.bitDepth); // 图像深度,即每个通道包含的位数
console.log(png.colorType); // 颜色类型,0 - 灰度,2 - rgb,3 - 索引,4 - 灰度+aloha,6 - rgba
console.log(png.alpha); // 是否使用alpha通道

let pixels = png.decode(); // 像素数据

gif解码器

const Gif = require('doimg').Gif;

let gif = new Gif(buffer);

console.log(gif.width); // 图像宽度
console.log(gif.height); // 图像高度
console.log(gif.bitDepth); // 图像深度
console.log(gif.backgroundColorIndex); // 背景颜色

let images = png.decode(); // 图片列表像素数据
let firstImg = images[0]; // 取图片列表中第一张

console.log(firstImg.left); // 图像左边偏移
console.log(firstImg.top); // 图像上边偏移
console.log(firstImg.width); // 图像宽度
console.log(firstImg.height); // 图像高度
console.log(firstImg.disposalMethod); // 处置方法,0 - 不使用处置方法,1 - 不处置图形,把图形从当前位置移去,2 - 回复到背景色,3 - 回复到先前状态
console.log(firstImg.userInputFlag); // 用户输入标志,指出是否期待用户有输入之后才继续进行下去,0 - 不期待,1 - 期待
console.log(firstImg.delayTime); // 延迟时间,单位1/100秒

jpeg解码器

const Jpeg = require('doimg').Jpeg;

let jpeg = new Jpeg(buffer);

console.log(jpeg.width); // 图像宽度
console.log(jpeg.height); // 图像高度
console.log(jpeg.thumbnailWidth); // 缩略图宽度
console.log(jpeg.thumbnailHeight); // 缩略图高度
console.log(jpeg.thumbnail); // 缩略图数据

let pixels = jpeg.decode(); // 像素数据

协议

MIT

doimg's People

Contributors

juneandgreen avatar

Watchers

James Cloos avatar  avatar

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.