You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To convert every file to a specific image format, you can pass a GraphicsMagick format string to the stream method, but you will also need to alter the FS.File instance as necessary in a beforeWrite function.
Images=newFS.Collection("images",{stores: [newFS.Store.FileSystem("images"),newFS.Store.FileSystem("thumbs",{beforeWrite: function(fileObj){// We return an object, which will change the// filename extension and type for this store only.return{extension: 'png',type: 'image/png'};},transformWrite: function(fileObj,readStream,writeStream){// Transform the image into a 10x10px PNG thumbnailgm(readStream).resize(60).stream('PNG').pipe(writeStream);// The new file size will be automatically detected and set for this store}})],filter: {allow: {contentTypes: ['image/*']//allow only images in this FS.Collection}}});
Note that this example requires the cfs-filesystem package.