I'm writing a script that takes an image and creates multiple variants of different sizes (like imgur, basically). Right now, I do the following for each variant using https://github.com/aheckmann/gm in node.js:
function(file, size, newfile, callback) {
gm(file)
.noProfile()
.quality(80)
.resize(size, size)
.write(newfile, callback)
}
- I assume that each time I resize the image, graphicsmagick reads the image form the disk and loads it into memory. Is this correct? If so, how can I make read from disk only once?
- Can I read the file from a stream, then run multiple resizes on a single stream? I don't know enough about streams, and when I tried doing this last, I got frustrated, gave up, and deleted that portion of the code.