Cfs thumb resize with aspect ratio


#1

i have this code
var anchofoto = 0;
createThumb = function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).size(function(err, value){
if(value.width > (value.height *1.3)){
anchofoto = 600;
}else {
anchofoto = 300;
}
}).resize(anchofoto).stream().pipe(writeStream);
};

Uploads = new FS.Collection("Uploads", {

stores: [
new FS.Store.FileSystem(“thumbs”, { transformWrite: createThumb , path: ‘…/…/…/…/…/public/fup/thumbs’ }),
new FS.Store.FileSystem(“images”, { path: ‘…/…/…/…/…/public/fup’ }),
],
filter: {
allow: {
contentTypes: [‘image/*’] //allow only images in this FS.Collection
}
}
});
i need to take the size of the image and analize the aspect ratio, and it is more width than height the reduction of the width is 600, else the reduction is 300.

but alwais take a width of the last image, or is this the first image take a 0. the size analisys is after of the resize. how i do to take the correct variable in the resize?.

sorry for my english!