Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blackbeam/pixbuf-simple
simple javascript interface to gdk-pixbuf 2.0
https://github.com/blackbeam/pixbuf-simple
Last synced: 20 days ago
JSON representation
simple javascript interface to gdk-pixbuf 2.0
- Host: GitHub
- URL: https://github.com/blackbeam/pixbuf-simple
- Owner: blackbeam
- Created: 2010-11-09T08:40:00.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2013-07-19T08:05:02.000Z (over 11 years ago)
- Last Synced: 2024-11-29T18:17:36.777Z (24 days ago)
- Language: C++
- Homepage:
- Size: 152 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## pixbuf-simple
Simple synchronous js interface to gdk-pixbuf 2.0### Requirements:
1. gdk-pixbuf 2.0### Installation:
```bash
npm install pixbuf-simple
```### Usage example:
```javascript
var p = require('pixbuf-simple');// Get list of supported formats
p.formats;// New pixbuf
var pb = new Pixbuf(/*has alpha*/ false, /*width*/ 2, /*height*/ 2);
console.log(pb);
// > { '0': { r: xx, g: xx, b: xx },
// > '1': { r: xx, g: xx, b: xx },
// > '2': { r: xx, g: xx, b: xx },
// > '3': { r: xx, g: xx, b: xx },
// > length: 4,
// > height: 2,
// > width: 2,
// > has_alpha: false,
// > pixels: }// Set pixel value
pb[3] = {r: 0, g: 255, b: 0};// New pixbuf from buffer of pixels
var npb = new Pixbuf(pb.pixels, pb.has_alpha, pb.width, pb.height);// New pixbuf from file
var fpb = new Pixbuf('path/to/file.jpeg');// New pixbuf from file at scale (refers to gdk_pixbuf_new_from_file_at_scale)
fpb = new Pixbuf('path/to/file.jpeg', /*width*/ 10, /*height*/ 20, /*preserve_aspect_ratio*/ false);// Encode pixbuf
var raw_image_buffer = fpb.toImage('png', {complression: '9'});
```### Additional info:
For list of supported image formats and options please refer to gdk-pixbuf 2.0 documentation.
Gdk-pixbuf has limited support of transparency.