4 Commits

Author SHA1 Message Date
c3f840e1be 1.0.17 2023-12-03 23:32:48 +01:00
6840d94517 fix(core): update 2023-12-03 23:32:47 +01:00
4600cde549 1.0.16 2023-12-03 23:30:58 +01:00
33e8ba5f30 fix(core): update 2023-12-03 23:30:58 +01:00
3 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartjimp",
"version": "1.0.15",
"version": "1.0.17",
"private": false,
"description": "a tool fr working with images in TypeScript",
"main": "dist_ts/index.js",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartjimp',
version: '1.0.15',
version: '1.0.17',
description: 'a tool fr working with images in TypeScript'
}

View File

@ -5,6 +5,7 @@ export interface IAssetVariation {
format?: 'avif' | 'webp' | 'png';
width?: number;
height?: number;
invert?: boolean;
}
export interface ISmartJimpOptions {
@ -65,6 +66,9 @@ export class SmartJimp {
let sharpImage = sharp(assetBufferArg);
sharpImage = sharpImage.resize(assetVariationArg.width, assetVariationArg.height);
const resultResize = sharpImage.resize(assetVariationArg.width, assetVariationArg.height);
if (assetVariationArg.invert) {
// TODO: implement invert
}
switch (assetVariationArg.format) {
case 'avif':
sharpImage = resultResize.avif();
@ -80,6 +84,9 @@ export class SmartJimp {
if (assetVariationArg.width || assetVariationArg.height) {
jimpImage = jimpImage.resize(assetVariationArg.width, assetVariationArg.height);
}
if (assetVariationArg.invert) {
jimpImage = jimpImage.invert();
}
switch (assetVariationArg.format) {
case 'png':
return await jimpImage.getBufferAsync(jimp.MIME_PNG);