pkrumins / node-jpeg

A nodejs C++ module that given a buffer with RGB or RGBA values creates a JPEG image in memory.
http://www.catonmat.net
64 stars 26 forks source link

Segmentation fault #10

Open misterjt opened 12 years ago

misterjt commented 12 years ago
var fs=require('fs');
var sys = require('util');
var Jpeg = require('jpeg').Jpeg;
var Buffer = require('buffer').Buffer;
fs.readFile("./jpeg-gradient.jpeg", function(error, rgba) { 
    console.log(error);
    console.log(rgba);
    var jpeg = new Jpeg(rgba, 720, 400, 'rgb');
    var jpeg_img = jpeg.encodeSync().toString('binary');
    fs.writeFileSync('./jpeg.jpeg', jpeg_img, 'binary');
})

Picture "./jpeg-gradient.jpeg" 100% exists.

This code return me

dima@Acer ~/api.chatster $ node photo.js null <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 43 00 0d 09 0a 0b 0a 08 0d 0b 0a 0b 0e 0e 0d 0f 13 20 15 13 12 12 13 27 1c 1e 17 20 ...> Segmentation fault