26 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
8566c5f57f 1.0.15 2023-12-03 23:09:49 +01:00
4cc5accff1 fix(core): update 2023-12-03 23:09:48 +01:00
2b82a4b74a 1.0.14 2023-12-03 19:04:37 +01:00
499b7e5f42 fix(core): update 2023-12-03 19:04:36 +01:00
6b1948d834 1.0.13 2023-12-03 18:57:45 +01:00
7b340ea783 fix(core): update 2023-12-03 18:57:44 +01:00
063905bfaa 1.0.12 2023-12-03 18:41:44 +01:00
f1ad45289a fix(core): update 2023-12-03 18:41:43 +01:00
193e174fd7 1.0.11 2023-12-03 18:10:36 +01:00
703d21c426 fix(core): update 2023-12-03 18:10:35 +01:00
2d83ebac4d 1.0.10 2023-12-03 16:35:52 +01:00
7454a52d03 fix(core): update 2023-12-03 16:35:51 +01:00
1e93429186 1.0.9 2023-12-03 16:32:53 +01:00
ee926e18a7 fix(core): update 2023-12-03 16:32:52 +01:00
02a6656869 1.0.8 2023-11-24 20:21:13 +01:00
b07aba76e9 fix(core): update 2023-11-24 20:21:12 +01:00
7fdeed160a 1.0.7 2023-11-24 20:09:24 +01:00
c6cd1dc38f fix(core): update 2023-11-24 20:09:23 +01:00
d2a47f403e 1.0.6 2023-11-24 20:08:49 +01:00
c8ab607959 fix(core): update 2023-11-24 20:08:48 +01:00
8170877c55 switch to new org scheme 2023-07-11 00:51:43 +02:00
99182bdb69 switch to new org scheme 2023-07-10 02:56:32 +02:00
14 changed files with 4092 additions and 2188 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

View File

@ -3,10 +3,10 @@
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartjimp", "gitrepo": "smartjimp",
"description": "a tool fr working with images in TypeScript", "description": "a tool fr working with images in TypeScript",
"npmPackagename": "@pushrocks/smartjimp", "npmPackagename": "@push.rocks/smartjimp",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks" "projectDomain": "push.rocks"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartjimp", "name": "@push.rocks/smartjimp",
"version": "1.0.5", "version": "1.0.17",
"private": false, "private": false,
"description": "a tool fr working with images in TypeScript", "description": "a tool fr working with images in TypeScript",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -9,24 +9,24 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild)", "build": "(tsbuild --allowimplicitany)",
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@git.zone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.39", "@git.zone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.15", "@git.zone/tstest": "^1.0.77",
"@pushrocks/tapbundle": "^5.0.4", "@push.rocks/tapbundle": "^5.0.8",
"@types/node": "^18.11.18" "@types/node": "^20.10.2"
}, },
"dependencies": { "dependencies": {
"@pushrocks/levelcache": "^3.0.3", "@push.rocks/levelcache": "^3.0.3",
"@pushrocks/smartfile": "^10.0.7", "@push.rocks/smartfile": "^11.0.4",
"@pushrocks/smarthash": "^3.0.1", "@push.rocks/smarthash": "^3.0.4",
"@pushrocks/smartpath": "^5.0.5", "@push.rocks/smartpath": "^5.0.5",
"@pushrocks/smartrequest": "^2.0.11", "@push.rocks/smartrequest": "^2.0.15",
"@types/sharp": "^0.31.1", "jimp": "^0.22.10",
"sharp": "^0.31.3" "sharp": "^0.33.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@ -43,5 +43,13 @@
"type": "module", "type": "module",
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
] ],
"repository": {
"type": "git",
"url": "git+https://gitlab.com/push.rocks/smartjimp.git"
},
"bugs": {
"url": "https://gitlab.com/push.rocks/smartjimp/issues"
},
"homepage": "https://gitlab.com/push.rocks/smartjimp#readme"
} }

5818
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
# @pushrocks/smartjimp # @push.rocks/smartjimp
a tool fr working with images in TypeScript a tool fr working with images in TypeScript
## Availabililty and Links ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartjimp) * [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartjimp)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartjimp) * [gitlab.com (source)](https://gitlab.com/pushrocks/smartjimp)
* [github.com (source mirror)](https://github.com/pushrocks/smartjimp) * [github.com (source mirror)](https://github.com/pushrocks/smartjimp)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartjimp/) * [docs (typedoc)](https://pushrocks.gitlab.io/smartjimp/)
@ -13,14 +13,14 @@ Status Category | Status Badge
-- | -- -- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartjimp/badges/master/pipeline.svg)](https://lossless.cloud) GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartjimp/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartjimp/badges/master/coverage.svg)](https://lossless.cloud) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartjimp/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartjimp)](https://lossless.cloud) npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartjimp)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartjimp)](https://lossless.cloud) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartjimp)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartjimp)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartjimp)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartjimp)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartjimp)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartjimp)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartjimp)](https://lossless.cloud)
## Usage ## Usage

View File

@ -1,17 +1,27 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@push.rocks/tapbundle';
import * as smartjimp from '../ts/index.js'; import * as smartjimp from '../ts/index.js';
import * as smartfile from '@pushrocks/smartfile'; import * as smartfile from '@push.rocks/smartfile';
let testSmartJimp: smartjimp.SmartJimp; let testSmartJimp: smartjimp.SmartJimp;
tap.test('first test', async () => { tap.test('first test', async () => {
testSmartJimp = new smartjimp.SmartJimp(); testSmartJimp = new smartjimp.SmartJimp({ mode: 'sharp'});
expect(testSmartJimp).toBeInstanceOf(smartjimp.SmartJimp); expect(testSmartJimp).toBeInstanceOf(smartjimp.SmartJimp);
}); });
tap.test('should be able to create a master', async () => { tap.test('should be able to create a master', async () => {
const convertedAsset = await testSmartJimp.getFromUrl('https://images.unsplash.com/photo-1673276628202-737bf3020ac2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=3774&q=80', {width: 200}); const smartfileInstance = await smartfile.SmartFile.fromUrl('https://images.unsplash.com/photo-1673276628202-737bf3020ac2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=3774&q=80')
(await smartfile.Smartfile.fromBuffer('.nogit/result.jpeg', convertedAsset)).write(); const convertedAsset = await testSmartJimp.getFromSmartfile(smartfileInstance, {width: 500});
(await smartfile.SmartFile.fromBuffer('.nogit/result.avif', convertedAsset)).write();
}); });
tap.test('should be able to use jimp', async () => {
const testSmartJimp = new smartjimp.SmartJimp({ mode: 'jimp'});
const smartfileInstance = await smartfile.SmartFile.fromUrl('https://images.unsplash.com/photo-1673276628202-737bf3020ac2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=3774&q=80')
const convertedAsset = await testSmartJimp.computeAssetVariation(smartfileInstance.contents, {
format: 'png',
});
(await smartfile.SmartFile.fromBuffer('.nogit/result2.png', convertedAsset)).write();
})
tap.start(); tap.start();

View File

@ -2,7 +2,7 @@
* autocreated commitinfo by @pushrocks/commitinfo * autocreated commitinfo by @pushrocks/commitinfo
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smartjimp', name: '@push.rocks/smartjimp',
version: '1.0.5', version: '1.0.17',
description: 'a tool fr working with images in TypeScript' description: 'a tool fr working with images in TypeScript'
} }

13
ts/plugins.ts Normal file
View File

@ -0,0 +1,13 @@
// node native
import * as path from 'path';
export { path };
// @pushrocks scope
import * as levelcache from '@push.rocks/levelcache';
import * as smartfile from '@push.rocks/smartfile';
import * as smarthash from '@push.rocks/smarthash';
import * as smartpath from '@push.rocks/smartpath';
import * as smartrequest from '@push.rocks/smartrequest';
export { levelcache, smartpath, smarthash, smartfile, smartrequest };

7
ts/plugins.typed.ts Normal file
View File

@ -0,0 +1,7 @@
import type * as sharpType from 'sharp';
export { type sharpType };
import type * as jimpType from 'jimp';
export { type jimpType };

View File

@ -1,89 +1,133 @@
import * as plugins from './smartjimp.plugins.js'; import * as plugins from './plugins.js';
import * as pluginsTyped from './plugins.typed.js';
export interface IDimensions { export interface IAssetVariation {
format?: 'avif' | 'webp' | 'png';
width?: number; width?: number;
height?: number; height?: number;
invert?: boolean;
}
export interface ISmartJimpOptions {
mode: 'sharp' | 'jimp';
} }
export class SmartJimp { export class SmartJimp {
public levelCache = new plugins.levelcache.LevelCache({ public levelCache = new plugins.levelcache.LevelCache({
cacheId: 'mastercache', cacheId: 'mastercache',
maxMemoryStorageInMB: 100, maxMemoryStorageInMB: 100,
maxDiskStorageInMB: 5000, maxDiskStorageInMB: 5000,
}); });
public options: ISmartJimpOptions;
constructor(optionsArg: ISmartJimpOptions) {
this.options = optionsArg;
}
/** /**
* get a key that is unique for a wanted asset variation * get a key that is unique for a wanted asset variation
*/ */
private getCacheKey( private getCacheKey(
sourceTypeArg: 'path' | 'url' | 'smartfile', sourceTypeArg: 'streamfile' | 'smartfile',
sourceIdArg: string, sourceIdArg: string,
wantedDimensionsArg?: IDimensions assetVariationArg?: IAssetVariation
) { ) {
return `${sourceTypeArg}_${sourceIdArg}_${ return `${sourceTypeArg}_${sourceIdArg}_${
wantedDimensionsArg assetVariationArg
? `${wantedDimensionsArg.width || 'auto' }x${wantedDimensionsArg.height || 'auto'}` ? `${assetVariationArg.width || 'auto'}x${assetVariationArg.height || 'auto'}`
: 'original' : 'original'
}`; }`;
} }
private async computeAssetVariation(assetBuffer: Buffer, wantedDimensions?: IDimensions) { sharpMod: typeof pluginsTyped.sharpType.default;
if (!wantedDimensions) { public async getSharpMod(): Promise<
return assetBuffer; typeof pluginsTyped.sharpType.default
> {
if (!this.sharpMod) {
this.sharpMod = (await import('sharp')).default;
} }
let sharpImage = plugins.sharp(assetBuffer); return this.sharpMod;
sharpImage = sharpImage.resize(wantedDimensions.width, wantedDimensions.height);
const result = await sharpImage.resize(wantedDimensions.width, wantedDimensions.height).jpeg().toBuffer();
return result;
} }
public async getFromPath(pathArg: string, wantedDimensionsArg?: IDimensions) { jimpMod: typeof pluginsTyped.jimpType;
const cacheKey = this.getCacheKey('path', pathArg, wantedDimensionsArg); public async getJimpMod(): Promise<typeof pluginsTyped.jimpType.default> {
const existingCacheEntry = await this.levelCache.retrieveCacheEntryByKey(cacheKey); if (!this.jimpMod) {
if (existingCacheEntry) { this.jimpMod = await import('jimp');
return existingCacheEntry.contents;
} else {
const originalAssetSmartfile = await plugins.smartfile.Smartfile.fromFilePath(pathArg);
const computedAssetBuffer = await this.computeAssetVariation(originalAssetSmartfile.contentBuffer, wantedDimensionsArg);
this.levelCache.storeCacheEntryByKey(cacheKey, new plugins.levelcache.CacheEntry({
contents: computedAssetBuffer,
ttl: 600000
}));
return computedAssetBuffer;
} }
return this.jimpMod.default;
} }
public async getFromUrl(urlArg: string, wantedDimensionsArg?: IDimensions) { public async computeAssetVariation(assetBufferArg: Buffer, assetVariationArg: IAssetVariation) {
const cacheKey = this.getCacheKey('url', urlArg, wantedDimensionsArg); if (this.options.mode === 'sharp') {
const existingCacheEntry = await this.levelCache.retrieveCacheEntryByKey(cacheKey); const sharp = await this.getSharpMod();
if (existingCacheEntry) { if (!assetVariationArg) {
return existingCacheEntry.contents; return assetBufferArg;
} else { }
const originalAssetBuffer = (await plugins.smartrequest.getBinary(urlArg)).body; let sharpImage = sharp(assetBufferArg);
const computedAssetBuffer = await this.computeAssetVariation(originalAssetBuffer, wantedDimensionsArg); sharpImage = sharpImage.resize(assetVariationArg.width, assetVariationArg.height);
this.levelCache.storeCacheEntryByKey(cacheKey, new plugins.levelcache.CacheEntry({ const resultResize = sharpImage.resize(assetVariationArg.width, assetVariationArg.height);
contents: computedAssetBuffer, if (assetVariationArg.invert) {
ttl: 600000 // TODO: implement invert
})); }
return computedAssetBuffer; switch (assetVariationArg.format) {
case 'avif':
sharpImage = resultResize.avif();
case 'webp':
sharpImage = resultResize.webp();
case 'png':
sharpImage = resultResize.png();
}
return sharpImage.toBuffer();
} else if (this.options.mode === 'jimp') {
const jimp = await this.getJimpMod();
let jimpImage = await jimp.read(assetBufferArg);
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);
default:
return await jimpImage.getBufferAsync(jimp.MIME_JPEG);
}
} }
} }
public async getFromSmartfile( public async getFromSmartfile(
smartfileArg: plugins.smartfile.Smartfile, smartfileArg: plugins.smartfile.SmartFile,
wantedDimensionsArg?: IDimensions wantedDimensionsArg?: IAssetVariation
) { ) {
const cacheKey = this.getCacheKey('url', await smartfileArg.getHash(), wantedDimensionsArg); const cacheKey = this.getCacheKey(
'smartfile',
await smartfileArg.getHash(),
wantedDimensionsArg
);
const existingCacheEntry = await this.levelCache.retrieveCacheEntryByKey(cacheKey); const existingCacheEntry = await this.levelCache.retrieveCacheEntryByKey(cacheKey);
if (existingCacheEntry) { if (existingCacheEntry) {
return existingCacheEntry.contents; return existingCacheEntry.contents;
} else { } else {
const computedAssetBuffer = await this.computeAssetVariation(smartfileArg.contentBuffer, wantedDimensionsArg); const computedAssetBuffer = await this.computeAssetVariation(
this.levelCache.storeCacheEntryByKey(cacheKey, new plugins.levelcache.CacheEntry({ smartfileArg.contentBuffer,
contents: computedAssetBuffer, wantedDimensionsArg
ttl: 600000 );
})); this.levelCache.storeCacheEntryByKey(
cacheKey,
new plugins.levelcache.CacheEntry({
contents: computedAssetBuffer,
ttl: 600000,
})
);
return computedAssetBuffer; return computedAssetBuffer;
} }
} }
public async createAvifImageFromBuffer(bufferArg: Buffer) {
const sharp = await this.getSharpMod();
const sharpImage = sharp(bufferArg);
const result = await sharpImage.avif().toBuffer();
return result;
}
} }

View File

@ -1,4 +1,4 @@
import * as plugins from './smartjimp.plugins.js'; import * as plugins from './plugins.js';
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../'); export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
export const nogitDir = plugins.path.join(packageDir, '.nogit/') export const nogitDir = plugins.path.join(packageDir, '.nogit/')

View File

@ -1,18 +0,0 @@
// node native
import * as path from 'path';
export { path };
// @pushrocks scope
import * as levelcache from '@pushrocks/levelcache';
import * as smartfile from '@pushrocks/smartfile';
import * as smarthash from '@pushrocks/smarthash';
import * as smartpath from '@pushrocks/smartpath';
import * as smartrequest from '@pushrocks/smartrequest';
export { levelcache, smartpath, smarthash, smartfile, smartrequest };
// third party scope
import sharp from 'sharp';
export { sharp };

View File

@ -3,8 +3,12 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"useDefineForClassFields": false, "useDefineForClassFields": false,
"target": "ES2022", "target": "ES2022",
"module": "ES2022", "module": "NodeNext",
"moduleResolution": "nodenext", "moduleResolution": "NodeNext",
"esModuleInterop": true "esModuleInterop": true,
} "verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
} }