Compare commits
No commits in common. 'f7699115409de4e3594210a017b79cf01de80416' and '9bfcbb3340b72ef737b10dd2dedbf8f1e793e6d0' have entirely different histories.
f769911540
...
9bfcbb3340
6 changed files with 31 additions and 145 deletions
@ -1,22 +0,0 @@ |
||||
'use strict'; |
||||
|
||||
module.exports = { |
||||
up(queryInterface, Sequelize) { |
||||
return Promise.all([ |
||||
queryInterface.addColumn( |
||||
'Users',
|
||||
'imageFileName',
|
||||
{ |
||||
type: Sequelize.STRING, |
||||
allowNull: false, |
||||
}, |
||||
) |
||||
]); |
||||
}, |
||||
|
||||
down(queryInterface, Sequelize) { |
||||
return Promise.all([ |
||||
queryInterface.removeColumn('Users', 'imageFileName'), |
||||
]); |
||||
}, |
||||
}; |
@ -1,34 +0,0 @@ |
||||
const fs = require('fs'); |
||||
const path = require('path'); |
||||
const jimp = require('jimp') |
||||
|
||||
|
||||
module.exports = function (image){ |
||||
return new Promise ((resolve, reject)=>{ |
||||
let imageAddress = path.join(__dirname + "/../public/images/" + image) |
||||
let imageNameWithOutExtn = image.slice(0 , image.indexOf('.') ) |
||||
jimp.read(imageAddress) |
||||
.then(lenna => { |
||||
return lenna |
||||
.resize(157, 142) // resize
|
||||
.quality(90) // set JPEG quality
|
||||
.write(`./public/images/resized/${imageNameWithOutExtn}.png`); // save
|
||||
}) |
||||
.then((res)=>{ |
||||
try { |
||||
|
||||
fs.unlinkSync(__dirname + '/../public/images/' + image) |
||||
console.log('original picture is deleted .....') |
||||
console.log('----------------------------') |
||||
} catch (err) { |
||||
console.log(err); |
||||
console.log('original picture not deleted .....') |
||||
} |
||||
resolve(res) |
||||
}) |
||||
.catch(err => { |
||||
reject(err) |
||||
}); |
||||
}) |
||||
|
||||
} |
Loading…
Reference in new issue