0

When I try to execute this simple example of code using gm and nodejs on Windows:

var gm = require('gm').subClass({imageMagick: true}); 
gm(50, 50, '#000F')
    .setFormat('img') 
    .fill('black') 
    .drawCircle( 50, 50, 60, 60 ) 
    .toBuffer(function( error, buffer ) {
        if( error ) { console.log( error ); return; }
        console.log( 'success: ' + buffer.length ); 
    } 
);

I get the error:

[Error: Stream yields empty buffer]

Why is this error happining and how can I solve it ?

Kara
  • 6,115
  • 16
  • 50
  • 57
Airton Gessner
  • 215
  • 2
  • 11

2 Answers2

0

I think your issue is with:

.setFormat('img')

Try setting it to something like 'png' or 'jpeg'.

chead23
  • 1,859
  • 11
  • 12
0

In my case the solution was to copy the magick program from its directory to convert.exe name and then the above code snippet started to work. (It might be that convert program of windows is tried to be used within gm, but even supplying appPath didn't help. )

Tuula
  • 176
  • 2
  • 10