Initial commit
This commit is contained in:
commit
e49726988c
5445 files changed
+1089914
No files matched your search
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "../src",
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "./build.json",
|
||||
"include": [
|
||||
"../src/**/*.ts",
|
||||
"../src/**/*.cts",
|
||||
"../src/**/*.tsx",
|
||||
"../src/**/*.json"
|
||||
],
|
||||
"exclude": [
|
||||
"../**/*.test.ts",
|
||||
"../src/**/*.mts",
|
||||
"../src/package.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "../.tshy-build/commonjs"
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"extends": "./build.json",
|
||||
"include": [
|
||||
"../src/**/*.ts",
|
||||
"../src/**/*.mts",
|
||||
"../src/**/*.tsx",
|
||||
"../src/**/*.json"
|
||||
],
|
||||
"exclude": [
|
||||
"../**/*.test.ts",
|
||||
"../src/package.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "../.tshy-build/esm"
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
> @jimp/js-bmp@1.5.0 build /Users/andrewlisowski/Documents/jimp/plugins/js-bmp
|
||||
> tshy
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
> @jimp/js-bmp@1.1.2 lint /Users/andrewlisowski/Documents/jimp/plugins/js-bmp
|
||||
> eslint .
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
|
||||
> @jimp/js-bmp@1.1.1 test:browser /Users/andrewlisowski/Documents/jimp/plugins/js-bmp
|
||||
> vitest --config vitest.config.browser.mjs "--watch=false" "--u"
|
||||
|
||||
|
||||
[7m[1m[36m RUN [39m[22m[27m [36mv1.4.0[39m [90m/Users/andrewlisowski/Documents/jimp/plugins/js-bmp[39m
|
||||
[2m[32m Browser runner started at http://localhost:5175/[39m[22m
|
||||
|
||||
[?25l [90m·[39m [2msrc/[22mindex[2m.test.ts[22m[2m (2)[22m
|
||||
[90m·[39m BMP[2m (2)[22m
|
||||
[90m·[39m load BMP
|
||||
[90m·[39m export BMP
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (2)[22m
|
||||
[33m❯[39m BMP[2m (2)[22m
|
||||
[33m⠙[39m load BMP
|
||||
[90m·[39m export BMP
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/[22mindex[2m.test.ts[22m[2m (2)[22m
|
||||
[32m✓[39m BMP[2m (2)[22m
|
||||
[32m✓[39m load BMP
|
||||
[32m✓[39m export BMP
|
||||
[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/[22mindex[2m.test.ts[22m[2m (2)[22m
|
||||
[32m✓[39m BMP[2m (2)[22m
|
||||
[32m✓[39m load BMP
|
||||
[32m✓[39m export BMP
|
||||
|
||||
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
||||
[2m Tests [22m [1m[32m2 passed[39m[22m[90m (2)[39m
|
||||
[2m Start at [22m 00:42:10
|
||||
[2m Duration [22m 6.37s[2m (transform 0ms, setup 0ms, collect 226ms, tests 55ms, environment 0ms, prepare 0ms)[22m
|
||||
|
||||
[?25h[?25h
|
||||
+1082
File diff suppressed because it is too large.
Load diff
+73
@@ -0,0 +1,73 @@
|
||||
# v1.5.0 (Sat Sep 07 2024)
|
||||
|
||||
### Release Notes
|
||||
|
||||
#### Add support for image decoder options ([#1336](https://github.com/jimp-dev/jimp/pull/1336))
|
||||
|
||||
Can now have options for the underlying image codecs
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- Add support for image decoder options [#1336](https://github.com/jimp-dev/jimp/pull/1336) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.1.3 (Mon Sep 02 2024)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.1.0 (Sun Sep 01 2024)
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.0.3 (Sat Aug 31 2024)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.0.2 (Sat Aug 31 2024)
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Oliver Moran
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<div align="center">
|
||||
<img width="200" height="200"
|
||||
src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
|
||||
<h1>@jimp/bmp</h1>
|
||||
<p>Default Jimp bmp encoder/decoder.</p>
|
||||
</div>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import * as BMP from "bmp-ts";
|
||||
import { Bitmap } from "@jimp/types";
|
||||
export type { BmpColor } from "bmp-ts";
|
||||
export { BmpCompression } from "bmp-ts";
|
||||
type Pretty<T> = {
|
||||
[K in keyof T]: T[K] extends (...args: any[]) => any ? T[K] : T[K] extends object ? Pretty<T[K]> : T[K];
|
||||
};
|
||||
export type EncodeOptions = Pretty<Partial<Pick<BMP.BmpImage, "palette" | "colors" | "importantColors" | "hr" | "vr" | "reserved1" | "reserved2">>>;
|
||||
export interface DecodeBmpOptions {
|
||||
toRGBA?: boolean;
|
||||
}
|
||||
declare function encode(image: Bitmap, options?: EncodeOptions): Buffer;
|
||||
declare function decode(data: Buffer, options?: DecodeBmpOptions): Bitmap;
|
||||
export declare function msBmp(): {
|
||||
mime: "image/x-ms-bmp";
|
||||
encode: typeof encode;
|
||||
decode: typeof decode;
|
||||
};
|
||||
export default function bmp(): {
|
||||
mime: "image/bmp";
|
||||
encode: typeof encode;
|
||||
decode: typeof decode;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,MAAM,EAAU,MAAM,aAAa,CAAC;AAE7C,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,KAAK,MAAM,CAAC,CAAC,IAAI;KAEd,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAChD,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACjB,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACZ,CAAC,CAAC,CAAC,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAChC,OAAO,CACL,IAAI,CACF,GAAG,CAAC,QAAQ,EACV,SAAS,GACT,QAAQ,GACR,iBAAiB,GACjB,IAAI,GACJ,IAAI,GACJ,WAAW,GACX,WAAW,CACd,CACF,CACF,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,iBAAS,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,UAqBzD;AAED,iBAAS,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAsBrC,MAAM,CACxB;AAED,wBAAgB,KAAK;;;;EAMpB;AAED,MAAM,CAAC,OAAO,UAAU,GAAG;;;;EAM1B"}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BmpCompression = void 0;
|
||||
exports.msBmp = msBmp;
|
||||
exports.default = bmp;
|
||||
const BMP = __importStar(require("bmp-ts"));
|
||||
const utils_1 = require("@jimp/utils");
|
||||
var bmp_ts_1 = require("bmp-ts");
|
||||
Object.defineProperty(exports, "BmpCompression", { enumerable: true, get: function () { return bmp_ts_1.BmpCompression; } });
|
||||
function encode(image, options = {}) {
|
||||
(0, utils_1.scan)({ bitmap: image }, 0, 0, image.width, image.height, function (_, __, index) {
|
||||
const red = image.data[index + 0];
|
||||
const green = image.data[index + 1];
|
||||
const blue = image.data[index + 2];
|
||||
const alpha = image.data[index + 3];
|
||||
image.data[index + 0] = alpha;
|
||||
image.data[index + 1] = blue;
|
||||
image.data[index + 2] = green;
|
||||
image.data[index + 3] = red;
|
||||
});
|
||||
return BMP.encode({ ...image, ...options }).data;
|
||||
}
|
||||
function decode(data, options) {
|
||||
const result = BMP.decode(data, options);
|
||||
(0, utils_1.scan)({ bitmap: result }, 0, 0, result.width, result.height, function (_, __, index) {
|
||||
// const alpha = result.data[index + 0]!;
|
||||
const blue = result.data[index + 1];
|
||||
const green = result.data[index + 2];
|
||||
const red = result.data[index + 3];
|
||||
result.data[index + 0] = red;
|
||||
result.data[index + 1] = green;
|
||||
result.data[index + 2] = blue;
|
||||
result.data[index + 3] = 0xff;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
function msBmp() {
|
||||
return {
|
||||
mime: "image/x-ms-bmp",
|
||||
encode,
|
||||
decode,
|
||||
};
|
||||
}
|
||||
function bmp() {
|
||||
return {
|
||||
mime: "image/bmp",
|
||||
encode,
|
||||
decode,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,sBAMC;AAED,sBAMC;AAlGD,4CAA8B;AAE9B,uCAAmC;AAInC,iCAAwC;AAA/B,wGAAA,cAAc,OAAA;AA8BvB,SAAS,MAAM,CAAC,KAAa,EAAE,UAAyB,EAAE;IACxD,IAAA,YAAI,EACF,EAAE,MAAM,EAAE,KAAK,EAAE,EACjB,CAAC,EACD,CAAC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G,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;QACtC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;QAEpC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAChC,CAAC,CACF,CAAC;IAEF,OAAO,MAAgB,CAAC;AAC1B,CAAC;AAED,SAAgB,KAAK;IACnB,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,MAAM;QACN,MAAM;KAC4B,CAAC;AACvC,CAAC;AAED,SAAwB,GAAG;IACzB,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,MAAM;QACN,MAAM;KACuB,CAAC;AAClC,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import * as BMP from "bmp-ts";
|
||||
import { Bitmap } from "@jimp/types";
|
||||
export type { BmpColor } from "bmp-ts";
|
||||
export { BmpCompression } from "bmp-ts";
|
||||
type Pretty<T> = {
|
||||
[K in keyof T]: T[K] extends (...args: any[]) => any ? T[K] : T[K] extends object ? Pretty<T[K]> : T[K];
|
||||
};
|
||||
export type EncodeOptions = Pretty<Partial<Pick<BMP.BmpImage, "palette" | "colors" | "importantColors" | "hr" | "vr" | "reserved1" | "reserved2">>>;
|
||||
export interface DecodeBmpOptions {
|
||||
toRGBA?: boolean;
|
||||
}
|
||||
declare function encode(image: Bitmap, options?: EncodeOptions): Buffer;
|
||||
declare function decode(data: Buffer, options?: DecodeBmpOptions): Bitmap;
|
||||
export declare function msBmp(): {
|
||||
mime: "image/x-ms-bmp";
|
||||
encode: typeof encode;
|
||||
decode: typeof decode;
|
||||
};
|
||||
export default function bmp(): {
|
||||
mime: "image/bmp";
|
||||
encode: typeof encode;
|
||||
decode: typeof decode;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,MAAM,EAAU,MAAM,aAAa,CAAC;AAE7C,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,KAAK,MAAM,CAAC,CAAC,IAAI;KAEd,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAChD,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACjB,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACZ,CAAC,CAAC,CAAC,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAChC,OAAO,CACL,IAAI,CACF,GAAG,CAAC,QAAQ,EACV,SAAS,GACT,QAAQ,GACR,iBAAiB,GACjB,IAAI,GACJ,IAAI,GACJ,WAAW,GACX,WAAW,CACd,CACF,CACF,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,iBAAS,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,UAqBzD;AAED,iBAAS,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAsBrC,MAAM,CACxB;AAED,wBAAgB,KAAK;;;;EAMpB;AAED,MAAM,CAAC,OAAO,UAAU,GAAG;;;;EAM1B"}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import * as BMP from "bmp-ts";
|
||||
import { scan } from "@jimp/utils";
|
||||
export { BmpCompression } from "bmp-ts";
|
||||
function encode(image, options = {}) {
|
||||
scan({ bitmap: image }, 0, 0, image.width, image.height, function (_, __, index) {
|
||||
const red = image.data[index + 0];
|
||||
const green = image.data[index + 1];
|
||||
const blue = image.data[index + 2];
|
||||
const alpha = image.data[index + 3];
|
||||
image.data[index + 0] = alpha;
|
||||
image.data[index + 1] = blue;
|
||||
image.data[index + 2] = green;
|
||||
image.data[index + 3] = red;
|
||||
});
|
||||
return BMP.encode({ ...image, ...options }).data;
|
||||
}
|
||||
function decode(data, options) {
|
||||
const result = BMP.decode(data, options);
|
||||
scan({ bitmap: result }, 0, 0, result.width, result.height, function (_, __, index) {
|
||||
// const alpha = result.data[index + 0]!;
|
||||
const blue = result.data[index + 1];
|
||||
const green = result.data[index + 2];
|
||||
const red = result.data[index + 3];
|
||||
result.data[index + 0] = red;
|
||||
result.data[index + 1] = green;
|
||||
result.data[index + 2] = blue;
|
||||
result.data[index + 3] = 0xff;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
export function msBmp() {
|
||||
return {
|
||||
mime: "image/x-ms-bmp",
|
||||
encode,
|
||||
decode,
|
||||
};
|
||||
}
|
||||
export default function bmp() {
|
||||
return {
|
||||
mime: "image/bmp",
|
||||
encode,
|
||||
decode,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAInC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;A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ACpB,yCAAyC;QACzC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;QACtC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;QAEpC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAChC,CAAC,CACF,CAAC;IAEF,OAAO,MAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,MAAM;QACN,MAAM;KAC4B,CAAC;AACvC,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,GAAG;IACzB,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,MAAM;QACN,MAAM;KACuB,CAAC;AAClC,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import shared from "@jimp/config-eslint/base.js";
|
||||
export default [...shared];
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"name": "@jimp/js-bmp",
|
||||
"version": "1.6.0",
|
||||
"repository": "jimp-dev/jimp",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "vitest",
|
||||
"test:browser": "vitest --config vitest.config.browser.mjs",
|
||||
"build": "tshy",
|
||||
"dev": "tshy --watch",
|
||||
"clean": "rm -rf node_modules .tshy .tshy-build dist .turbo"
|
||||
},
|
||||
"author": "Andrew Lisowski <lisowski54@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@jimp/config-eslint": "1.6.0",
|
||||
"@jimp/config-typescript": "1.6.0",
|
||||
"@jimp/config-vitest": "1.6.0",
|
||||
"@jimp/js-png": "1.6.0",
|
||||
"@jimp/test-utils": "1.6.0",
|
||||
"@types/node": "^18.19.48",
|
||||
"@vitest/browser": "^2.0.5",
|
||||
"eslint": "^9.9.1",
|
||||
"tshy": "^3.0.2",
|
||||
"typescript": "^5.5.4",
|
||||
"vite-plugin-node-polyfills": "^0.22.0",
|
||||
"vitest": "^2.0.5"
|
||||
},
|
||||
"tshy": {
|
||||
"exclude": [
|
||||
"**/*.test.ts"
|
||||
],
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@jimp/core": "1.6.0",
|
||||
"@jimp/types": "1.6.0",
|
||||
"@jimp/utils": "1.6.0",
|
||||
"bmp-ts": "^1.0.9"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"module": "./dist/esm/index.js",
|
||||
"gitHead": "c88abe6046dccbdb6e4f5f00c3dd403c81d83515"
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 126 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 111 KiB |
+17
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { createJimp } from "@jimp/core";
|
||||
import { getTestImagePath } from "@jimp/test-utils";
|
||||
|
||||
import png from "@jimp/js-png";
|
||||
import bmp from "./index.js";
|
||||
|
||||
const jimp = createJimp({ formats: [bmp, png] });
|
||||
|
||||
describe("BMP", () => {
|
||||
test("uses correct colors for BMP", async function () {
|
||||
const expectedImg = await jimp.read(getTestImagePath("windows95.png"));
|
||||
const image = await jimp.read(getTestImagePath("windows95.bmp"));
|
||||
|
||||
expect(image.bitmap.data).toEqual(expectedImg.bitmap.data);
|
||||
});
|
||||
});
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { createJimp } from "@jimp/core";
|
||||
import { getTestImagePath } from "@jimp/test-utils";
|
||||
|
||||
import png from "@jimp/js-png";
|
||||
import bmp from "./index.js";
|
||||
|
||||
const jimp = createJimp({ formats: [bmp, png] });
|
||||
|
||||
describe("BMP", () => {
|
||||
test("load BMP", async () => {
|
||||
const image = await jimp.read(getTestImagePath("windows95.bmp"));
|
||||
|
||||
expect(image.getPixelColor(10, 10)).toBe(0xeff7f7ff);
|
||||
expect(image.getPixelColor(150, 80)).toBe(0x73add6ff);
|
||||
expect(image.getPixelColor(190, 200)).toBe(0xf7c300ff);
|
||||
});
|
||||
|
||||
test("export BMP", async () => {
|
||||
const image = jimp.fromBitmap({
|
||||
width: 3,
|
||||
height: 3,
|
||||
data: [
|
||||
0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff,
|
||||
0xff00ffff, 0x8000ffff, 0x0000ffff,
|
||||
],
|
||||
});
|
||||
const buffer = await image.getBuffer("image/bmp");
|
||||
|
||||
expect(buffer.toString()).toMatch(/^BM/);
|
||||
});
|
||||
});
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
import * as BMP from "bmp-ts";
|
||||
|
||||
import { scan } from "@jimp/utils";
|
||||
import { Bitmap, Format } from "@jimp/types";
|
||||
|
||||
export type { BmpColor } from "bmp-ts";
|
||||
export { BmpCompression } from "bmp-ts";
|
||||
|
||||
type Pretty<T> = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[K in keyof T]: T[K] extends (...args: any[]) => any
|
||||
? T[K]
|
||||
: T[K] extends object
|
||||
? Pretty<T[K]>
|
||||
: T[K];
|
||||
};
|
||||
|
||||
export type EncodeOptions = Pretty<
|
||||
Partial<
|
||||
Pick<
|
||||
BMP.BmpImage,
|
||||
| "palette"
|
||||
| "colors"
|
||||
| "importantColors"
|
||||
| "hr"
|
||||
| "vr"
|
||||
| "reserved1"
|
||||
| "reserved2"
|
||||
>
|
||||
>
|
||||
>;
|
||||
|
||||
export interface DecodeBmpOptions {
|
||||
toRGBA?: boolean;
|
||||
}
|
||||
|
||||
function encode(image: Bitmap, options: EncodeOptions = {}) {
|
||||
scan(
|
||||
{ bitmap: image },
|
||||
0,
|
||||
0,
|
||||
image.width,
|
||||
image.height,
|
||||
function (_, __, index) {
|
||||
const red = image.data[index + 0]!;
|
||||
const green = image.data[index + 1]!;
|
||||
const blue = image.data[index + 2]!;
|
||||
const alpha = image.data[index + 3]!;
|
||||
|
||||
image.data[index + 0] = alpha;
|
||||
image.data[index + 1] = blue;
|
||||
image.data[index + 2] = green;
|
||||
image.data[index + 3] = red;
|
||||
}
|
||||
);
|
||||
|
||||
return BMP.encode({ ...image, ...options }).data;
|
||||
}
|
||||
|
||||
function decode(data: Buffer, options?: DecodeBmpOptions) {
|
||||
const result = BMP.decode(data, options);
|
||||
|
||||
scan(
|
||||
{ bitmap: result },
|
||||
0,
|
||||
0,
|
||||
result.width,
|
||||
result.height,
|
||||
function (_, __, index) {
|
||||
// const alpha = result.data[index + 0]!;
|
||||
const blue = result.data[index + 1]!;
|
||||
const green = result.data[index + 2]!;
|
||||
const red = result.data[index + 3]!;
|
||||
|
||||
result.data[index + 0] = red;
|
||||
result.data[index + 1] = green;
|
||||
result.data[index + 2] = blue;
|
||||
result.data[index + 3] = 0xff;
|
||||
}
|
||||
);
|
||||
|
||||
return result as Bitmap;
|
||||
}
|
||||
|
||||
export function msBmp() {
|
||||
return {
|
||||
mime: "image/x-ms-bmp",
|
||||
encode,
|
||||
decode,
|
||||
} satisfies Format<"image/x-ms-bmp">;
|
||||
}
|
||||
|
||||
export default function bmp() {
|
||||
return {
|
||||
mime: "image/bmp",
|
||||
encode,
|
||||
decode,
|
||||
} satisfies Format<"image/bmp">;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "@jimp/config-typescript/base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import config from "@jimp/config-vitest/browser";
|
||||
|
||||
export default config;
|
||||
Reference in new issue
Block a user