aheckmann/gm — Issue #35: streamed content-length?
Author: japrescott
Created: 2012-02-11 13:15:19+00:00
State: open

Hey, I've been using GM for some time and am quite happy with how it makes my life easier :)
I've been trying to wrap my head around a new approach I'm trying and wondering why it isn't working as expected.
I'm using following code and want to push the stream to my amazon s3 bucket with aws2js module;

```javascript
var readStream = fs.createReadStream('/path/to/my/img.png');
gm(readStream, 'img.png')
.stream(function (err, stdout, stderr) {
s3.putStream(path, stdout, 'public-read', {'content-type': 'image/png', 'content-length': ?????}, function (err, result) {
....
});
});
```

everything works fine with aws2js and streams, IF I know the content-length (when I just directly store the picture without resize). But when I don't specify the content-length, it doesnt work and my file ends up beeing 0bytes in size.
Since I'll be wanting to resize the picture and then send it to my bucket, I'll need to know how big the resized img will be.

Is there a way, how I can retrieve that information?

Thank you for your help in kicking me in the right direction :)