Skip to content

Commit

Permalink
Step 20.6: Resize images
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kisiela authored and Dotan Simha committed Nov 22, 2016
1 parent 7ad5cc1 commit d9bfbee
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion imports/api/images/store.js
Expand Up @@ -3,7 +3,19 @@ import { Images, Thumbs } from './collection';

export const ThumbsStore = new UploadFS.store.GridFS({
collection: Thumbs,
name: 'thumbs'
name: 'thumbs',
transformWrite(from, to, fileId, file) {
// Resize to 32x32
const gm = require('gm');

gm(from, file.name)
.resize(32, 32)
.gravity('Center')
.extent(32, 32)
.quality(75)
.stream()
.pipe(to);
}
});

export const ImagesStore = new UploadFS.store.GridFS({
Expand Down

0 comments on commit d9bfbee

Please sign in to comment.