-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresize.js
48 lines (41 loc) · 1015 Bytes
/
resize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2019, University of Colorado Boulder
// @author Jonathan Olson (PhET Interactive Simulations)
/* global require */
const grunt = require( 'grunt' );
const jimp = require( 'jimp' );
const names = [
'Bricks25_AO.jpg',
'Bricks25_col.jpg',
'Bricks25_nrm.jpg',
'DiamondPlate01_col.jpg',
'DiamondPlate01_met.jpg',
'DiamondPlate01_nrm.jpg',
'DiamondPlate01_rgh.jpg',
'Ice01_alpha.jpg',
'Ice01_col.jpg',
'Ice01_nrm.jpg',
'Metal08_col.jpg',
'Metal08_met.jpg',
'Metal08_nrm.jpg',
'Metal08_rgh.jpg',
'Metal10_col.jpg',
'Metal10_met.jpg',
'Metal10_nrm.jpg',
'Metal10_rgh.jpg',
'Wood26_col.jpg',
'Wood26_nrm.jpg',
'Wood26_rgh.jpg'
];
names.forEach( name => {
console.log( new jimp( `assets/${name}`, function() {
this.quality( 95 );
this.resize( 256, 256 ).getBuffer( jimp.MIME_JPEG, ( error, buffer ) => {
if ( error ) {
throw error;
}
else {
grunt.file.write( `images/${name}`, buffer );
}
} );
} ) );
} );