1

I have a Node.js server (irrelevant) that does image manipulation with ImageMagick. Basically, I can POST an image to the server and it will respond with the transformed image.

Right now I’m just writing the POSTed image to a file and launching ImageMagick as a child process which write the transformed image to a new file and then I send that new file to the POSTer. I would like to avoid writing to disk in order to speed things up. Can this ImageMagick process accept streaming input and give me a stream as output?

As an example, this is one of the most complicated commands I use right now:

/usr/local/opt/imagemagick/bin/convert \( '/Users/shawn/Work/vigour-img/originals/7ajy06' -resize '150x150^' -gravity 'Center' -crop '150x150+0+0' \) \( '/Users/shawn/Work/vigour-img/images/avatarMask.png' -resize '150x150' -gravity 'Center' \) -compose 'CopyOpacity' -composite '/Users/shawn/Work/vigour-img/out/1bl6jm9.png'

This relies on /Users/shawn/Work/vigour-img/originals/7ajy06 and /Users/shawn/Work/vigour-img/images/avatarMask.png existing on disk and writes the result to /Users/shawn/Work/vigour-img/out/1bl6jm9.png.

If instead I could stream the input files and get the result as a stream, there would be no need to write to disk, thus greatly improving performance (I think).

1
  • I don't know, writing to a file and the reading that file and sending it over http seems longer than writing directly to the http response... In both cases, ImageMagich will have the whole image in memory for some time (except if I use this stream command you mention). Writing to a file or writing to an http response should be pretty much the same... As for the stream command, it's unclear to me how to use it in my case. I will have to spend more time on this and try things out. Thanks for the tip.
    – Shawn
    Sep 13, 2015 at 21:00

0

You must log in to answer this question.

Browse other questions tagged .