Upgrade deps
This commit is contained in:
parent
207c12973e
commit
d2178c8ee6
6 changed files with 776 additions and 664 deletions
|
@ -10,56 +10,26 @@ const types = {
|
|||
gif: jimp.MIME_JPEG,
|
||||
};
|
||||
|
||||
function cover(path, type, size) {
|
||||
return new Promise((resolve, reject) => {
|
||||
jimp.read(path, (errIn, image) => {
|
||||
debug('Image Opened');
|
||||
if (errIn) {
|
||||
reject(errIn);
|
||||
}
|
||||
const align = jimp.HORIZONTAL_ALIGN_CENTER | jimp.VERTICAL_ALIGN_MIDDLE;
|
||||
|
||||
image.quality(80).cover(size.width, size.height, (errOut, resized) => {
|
||||
debug('Image Resized');
|
||||
if (errOut) {
|
||||
reject(errOut);
|
||||
}
|
||||
async function cover(path, type, size) {
|
||||
const image = await jimp.read(path);
|
||||
debug('Image Opened');
|
||||
debug(size);
|
||||
const resized = await image.cover(size.width, size.height, align);
|
||||
debug('Image Resized');
|
||||
|
||||
resized.getBuffer(types[type], (errBuf, buffer) => {
|
||||
debug('Image Buffered');
|
||||
if (errBuf) {
|
||||
reject(errBuf);
|
||||
}
|
||||
resolve(buffer);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return await resized.quality(80).getBufferAsync(types[type]);
|
||||
}
|
||||
|
||||
function scale(path, type, size) {
|
||||
return new Promise((resolve, reject) => {
|
||||
jimp.read(path, (errIn, image) => {
|
||||
debug('Image Opened');
|
||||
if (errIn) {
|
||||
reject(errIn);
|
||||
}
|
||||
async function scale(path, type, size) {
|
||||
const image = await jimp.read(path);
|
||||
debug('Image Opened');
|
||||
|
||||
image.quality(80).cover(size.width, size.height, (errOut, resized) => {
|
||||
debug('Image Resized');
|
||||
if (errOut) {
|
||||
reject(errOut);
|
||||
}
|
||||
const resized = await image.cover(size.width, size.height, align);
|
||||
debug('Image Resized');
|
||||
|
||||
resized.getBuffer(types[type], (errBuf, buffer) => {
|
||||
debug('Image Buffered');
|
||||
if (errBuf) {
|
||||
reject(errBuf);
|
||||
}
|
||||
resolve(buffer);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return await resized.quality(80).getBufferAsync(types[type]);
|
||||
}
|
||||
|
||||
export default function resize(path, type, currentSize, newSize) {
|
||||
|
|
|
@ -22,3 +22,5 @@ export default function init() {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
fs.mkdirSync(path.join('/export', 'hostr'));
|
Loading…
Add table
Add a link
Reference in a new issue