Error: write EPIPE with node.js and imagemagick
Asked Answered
B

2

13

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");
    imagemagick.resize({
           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?

/Users/ik/Dropbox/snapgram/public/photos/4af1e720-a662-11e3-952c-61812ab60f67.jpg

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: write EPIPE
    at errnoException (net.js:904:11)
    at Object.afterWrite (net.js:720:19)
computername:snapgram ik$ 
Boniface answered 11/3, 2014 at 20:56 Comment(2)
Have you been able to find where is comming from yet? it's happening to me too.Chalcography
I have exactly the same error randomly using a Meteor app on node.js. Any idea?Kimble
M
9

I was getting this same error and discovered this issue:

https://github.com/aheckmann/gm/issues/209

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

Multilingual answered 15/6, 2014 at 16:33 Comment(1)
I installed graphicsmagick and imagemagick to windows but still getting the error.Ekaterinodar
M
3

Make sure both imagemagick and graphicsmagick are installed on your machine.

To install graphicsmagick on ubuntu,

$ sudo add-apt-repository ppa:dhor/myway
$ sudo apt-get update
$ sudo apt-get install graphicsmagick
Malacology answered 4/7, 2014 at 7:39 Comment(1)
I installed graphicsmagick and imagemagick to windows but still getting the error.Ekaterinodar

© 2022 - 2024 — McMap. All rights reserved.