GridFS and GraphicsMagick

I’ve been using cfs:grids for some time, but am having trouble resizing images placed in multiple stores. Until now I used a single store. I have added stores for the original image, a web optimized size, and a thumbnail size. The stores seem to be working. Images are being put into them and I can retrieve them by store. The problem is they are not being resized. I’ve followed the examples I’ve found online, but no joy. GM is installed on the development machine and I’ve been able to resize files from the command line using the convert command. Here’s the meteor code I’ve got now. Any help is appreciated.

var imageFileStore = new FS.Store.GridFS(‘imagefiles’, {
maxTries: 1
});

var imageThumbFileStore = new FS.Store.GridFS(‘imagethumbfiles’, {
maxTries: 1,
transformWrite: createThumbFile
});

var imageWebFileStore = new FS.Store.GridFS(‘imagewebfiles’, {
maxTries: 1,
transformWrite: createWebFile
});

var createThumbFile = function(fileObj, readStream, writeStream) {
// Transform the image into a 256x256px thumbnail
gm(readStream, fileObj.name()).resize(‘256’, ‘256’).stream().pipe(writeStream);
};

var createWebFile = function(fileObj, readStream, writeStream) {
// Transform the image into a 1920x1200px image
gm(readStream, fileObj.name()).resize(‘1920’, ‘1200’).stream().pipe(writeStream);
};

Imagefiles = new FS.Collection(‘imagefiles’, {
stores: [
imageFileStore,
imageThumbFileStore,
imageWebFileStore
],
});

Imagefiles.allow({
insert:function(){
return true;
},
update:function(){
return true;
},
remove:function(){
return true;
},
download:function(){
return true;
}
});

Meteor.methods({
addImagefile: function(theFile) {
var user = Meteor.user();
if(!user) {
throw new Meteor.Error(401, “You need to login to post new items”);
}

    var imagefileId = Imagefiles.insert(theFile,function(err,fileObj){
        if(!err){
            //do something if there is no error.
        }
    });

    return imagefileId;
},

removeImagefile: function(currentPostId){
    return Imagefiles.remove({imageId: currentPostId});
}

});

not helping with your current issue, but I had also fiddled with GridFS before and I really do suggest going for some more automatic solution like filestack just because you get all the features you need in a hassle free way.

For example querying an image should really be as simple as http://domain.com/image/dog1.jpg?width=300 (notice the dynamic resize).

Thanks for the response. We’ve got a commitment to MongoDB and GridFS for this. The GridFS portion is working fine. It’s the GraphicsMagick resizing that’s not happening. Still working on it.

All is working well today. Maybe I needed to restart my machine after installation of GraphicsMagick???

Did you slove this issue?