iank iank - 2 months ago 31
Javascript Question

Error: write EPIPE with node.js and imagemagick

I'm lost as to where this error is coming from, and I'm hoping you can help me. I'm new to node and am trying to resize an image with imagemagick:

var express = require('express'),
fs = require('fs'),
gm = require('gm'),
imagemagick = require('imagemagick'),
var gm = require('gm').subClass({ imageMagick: true });
var app = express();

app.get('/', function (req, res) {
console.log(__dirname + "/public/photos/4af1e720-a662-11e3-952c-61812ab60f67.jpg");
srcData: fs.readFileSync(__dirname + "/public/photos/4af1e720-a662-11e3-952c-61812ab60f67.jpg", 'binary'),
width: "400"
}, function(err,stdout,stderr){
if (err) console.log(err);
fs.writeFile(__dirname + "/public/photos/thumbnail/4af1e720-a662-11e3-952c-61812ab60f67.jpg", stdout, 'binary');

I get the following:

I've already checked that the folder thumbnail/ exists, and that the image exists. Do you know what else could be going on?


throw er; // Unhandled 'error' event
Error: write EPIPE
at errnoException (net.js:904:11)
at Object.afterWrite (net.js:720:19)
computername:snapgram ik$


I was getting this same error and discovered this issue:


You may need both imagemagick and graphicsmagick installed. That solved my issue.