Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
a2b408a7bf | |||
67fdcf0362 | |||
c3f840e1be | |||
6840d94517 | |||
4600cde549 | |||
33e8ba5f30 |
15
package.json
15
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@push.rocks/smartjimp",
|
||||
"version": "1.0.15",
|
||||
"version": "1.0.18",
|
||||
"private": false,
|
||||
"description": "a tool fr working with images in TypeScript",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -10,23 +10,24 @@
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
"buildDocs": "tsdoc",
|
||||
"localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.66",
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^1.0.77",
|
||||
"@git.zone/tstest": "^1.0.86",
|
||||
"@push.rocks/tapbundle": "^5.0.8",
|
||||
"@types/node": "^20.10.2"
|
||||
"@types/node": "^20.11.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"@push.rocks/levelcache": "^3.0.3",
|
||||
"@push.rocks/levelcache": "^3.0.8",
|
||||
"@push.rocks/smartfile": "^11.0.4",
|
||||
"@push.rocks/smarthash": "^3.0.4",
|
||||
"@push.rocks/smartpath": "^5.0.5",
|
||||
"@push.rocks/smartrequest": "^2.0.15",
|
||||
"jimp": "^0.22.10",
|
||||
"sharp": "^0.33.0"
|
||||
"sharp": "^0.33.2"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
1163
pnpm-lock.yaml
generated
1163
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartjimp',
|
||||
version: '1.0.15',
|
||||
version: '1.0.18',
|
||||
description: 'a tool fr working with images in TypeScript'
|
||||
}
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user