ndarray-pixels
Advanced tools
Comparing version 1.0.0 to 2.0.0
import type { NdArray } from 'ndarray'; | ||
export declare type GetPixelsCallback = (err: string | Event | null, pixels?: NdArray) => void; | ||
export type GetPixelsCallback = (err: string | Event | null, pixels?: NdArray) => void; | ||
export default getPixels; | ||
declare function getPixels(path: string, callback: GetPixelsCallback): void; | ||
declare function getPixels(path: string | Uint8Array, type: string, callback: GetPixelsCallback): void; |
{ | ||
"name": "ndarray-pixels", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "ndarray-pixels", | ||
"main": "./dist/ndarray-pixels.js", | ||
"type": "module", | ||
"sideEffects": false, | ||
"types": "./dist/index.d.ts", | ||
"main": "./dist/ndarray-pixels-node.cjs", | ||
"module": "./dist/ndarray-pixels-browser.modern.js", | ||
"types": "./dist/index.d.ts", | ||
"sideEffects": false, | ||
"exports": { | ||
"node": { | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/ndarray-pixels-node.cjs", | ||
"default": "./dist/ndarray-pixels-node.modern.js" | ||
}, | ||
"default": { | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/ndarray-pixels-browser.cjs", | ||
"default": "./dist/ndarray-pixels-browser.modern.js" | ||
} | ||
}, | ||
"repository": "github:donmccurdy/ndarray-pixels", | ||
@@ -13,10 +26,9 @@ "author": "Don McCurdy <dm@donmccurdy.com>", | ||
"scripts": { | ||
"dist": "yarn dist:node && yarn dist:browser:modern && yarn dist:browser:cjs", | ||
"dist:node": "microbundle build --raw --target node --format cjs src/index.ts --output dist/ndarray-pixels.js", | ||
"dist:browser:modern": "microbundle build --raw --target web --format modern src/index.ts --output dist/ndarray-pixels-browser.js --alias get-pixels=./browser-get-pixels.ts,save-pixels=./browser-save-pixels.ts", | ||
"dist:browser:cjs": "microbundle build --raw --target web --format cjs src/index.ts --output dist/ndarray-pixels-browser.js --alias get-pixels=./browser-get-pixels.ts,save-pixels=./browser-save-pixels.ts", | ||
"dist": "yarn dist:node && yarn dist:browser", | ||
"dist:node": "microbundle build --raw --target node --format modern,cjs src/index.ts --output dist/ndarray-pixels-node.js", | ||
"dist:browser": "microbundle build --raw --target web --format modern,cjs src/index.ts --output dist/ndarray-pixels-browser.js --alias get-pixels=./browser-get-pixels.ts,save-pixels=./browser-save-pixels.ts", | ||
"clean": "rm -rf dist/*", | ||
"test": "yarn test:node && yarn test:browser", | ||
"test:node": "tape test/node.test.js | tap-spec", | ||
"test:browser": "browserify test/browser.test.js | tape-run | tap-spec", | ||
"test:node": "tape test/node.test.cjs | tap-spec", | ||
"test:browser": "browserify test/browser.test.cjs | tape-run | tap-spec", | ||
"docs": "typedoc src/index.ts --plugin typedoc-plugin-markdown --out ./docs --hideBreadcrumbs && cat docs/modules.md | tail -n +12 | replace-between --target README.md --token API && rm -rf docs", | ||
@@ -35,21 +47,21 @@ "preversion": "yarn dist && yarn test", | ||
"devDependencies": { | ||
"@types/get-pixels": "3.3.1", | ||
"@types/ndarray-ops": "1.2.1", | ||
"@types/node": "16.9.2", | ||
"@types/get-pixels": "3.3.2", | ||
"@types/ndarray-ops": "1.2.4", | ||
"@types/node": "18.14.0", | ||
"@types/save-pixels": "2.3.2", | ||
"@types/tape": "4.13.2", | ||
"@typescript-eslint/eslint-plugin": "4.31.1", | ||
"@typescript-eslint/parser": "4.31.1", | ||
"@typescript-eslint/eslint-plugin": "5.53.0", | ||
"@typescript-eslint/parser": "5.53.0", | ||
"browserify": "17.0.0", | ||
"eslint": "7.32.0", | ||
"microbundle": "0.13.3", | ||
"regenerator-runtime": "0.13.9", | ||
"eslint": "8.34.0", | ||
"microbundle": "0.15.1", | ||
"regenerator-runtime": "0.13.11", | ||
"replace-between": "0.0.8", | ||
"source-map-support": "0.5.20", | ||
"source-map-support": "0.5.21", | ||
"tap-spec": "5.0.0", | ||
"tape": "5.3.1", | ||
"tape-run": "9.0.0", | ||
"typedoc": "0.22.3", | ||
"typedoc-plugin-markdown": "3.11.0", | ||
"typescript": "4.4.3" | ||
"tape": "5.6.3", | ||
"tape-run": "10.0.0", | ||
"typedoc": "0.23.25", | ||
"typedoc-plugin-markdown": "3.14.0", | ||
"typescript": "4.9.5" | ||
}, | ||
@@ -56,0 +68,0 @@ "files": [ |
@@ -40,6 +40,13 @@ # ndarray-pixels | ||
// read | ||
const pixels = await getPixels(bytesIn, 'image/png'); // Uint8Array -> ndarray | ||
// ... modify ndarray ... | ||
// modify | ||
for (let i = 0; i < pixels.shape[0]; ++i) { | ||
for (let j = 0; j < pixels.shape[1]; ++j) { | ||
pixels.set(i, j, 255); | ||
} | ||
} | ||
// write | ||
const bytesOut = await savePixels(pixels, 'image/png'); // ndarray -> Uint8Array | ||
@@ -56,6 +63,14 @@ ``` | ||
const bufferIn = fs.readFileSync('./input.png'); | ||
// read | ||
const pixels = await getPixels(bufferIn, 'image/png'); // Uint8Array -> ndarray | ||
// ... modify ndarray ... | ||
// modify | ||
for (let i = 0; i < pixels.shape[0]; ++i) { | ||
for (let j = 0; j < pixels.shape[1]; ++j) { | ||
pixels.set(i, j, 255); | ||
} | ||
} | ||
// write | ||
const bufferOut = await savePixels(pixels, 'image/png'); // ndarray -> Uint8Array | ||
@@ -93,3 +108,3 @@ fs.writeFileSync('./output.png', bufferOut); | ||
[index.ts:17](https://github.com/donmccurdy/ndarray-pixels/blob/3676ddc/src/index.ts#L17) | ||
[index.ts:17](https://github.com/donmccurdy/ndarray-pixels/blob/ed78feb/src/index.ts#L17) | ||
@@ -124,3 +139,3 @@ ___ | ||
[index.ts:48](https://github.com/donmccurdy/ndarray-pixels/blob/3676ddc/src/index.ts#L48) | ||
[index.ts:48](https://github.com/donmccurdy/ndarray-pixels/blob/ed78feb/src/index.ts#L48) | ||
<!--- API END ---> |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
65397
17
467
138
Yes