在我的演示中,我使用了https://github.com/tomitrescak/meteor-uploads包来上传图片,它的工作方式非常出色。现在我想在上传文件之前调用我的图像处理函数。
一旦我的图像处理功能完成,我想开始将图像上传到我的本地(这已经通过meteor-uploads包工作)。
如何实现这一目标?
发布于 2015-03-09 20:00:41
我会改用CollectionFS。它们具有图像处理( imagemagick,graphicsmagick)功能,可用于文件文件上传。因此,当您使用CollectionFS定义集合时,请使用:
Images = new FS.Collection("images", {
stores: [
new FS.Store.FileSystem("thumbs", { transformWrite: createThumb }),
new FS.Store.FileSystem("images"),
],
filter: {
allow: {
contentTypes: ['image/*'] //allow only images in this FS.Collection
}
}
});
var createThumb = function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
};注意,在将图像插入到集合images中的特定存储thumbs下之前,createThumb在function createThumb (gm)中使用images为您调整图像大小。
https://stackoverflow.com/questions/28939105
复制相似问题