Initial commit
This commit is contained in:
commit
e49726988c
5445 files changed
+1089914
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Filter method is a single-byte integer that indicates the preprocessing method applied to the image data before compression.
|
||||
*/
|
||||
export declare enum PNGFilterType {
|
||||
AUTO = -1,
|
||||
/** scanline is transmitted unmodified */
|
||||
NONE = 0,
|
||||
/** filter transmits the difference between each byte and the value of the corresponding byte of the prior pixel */
|
||||
SUB = 1,
|
||||
/** The Up() filter is just like the Sub() filter except that the pixel immediately above the current pixel, rather than just to its left, is used as the predictor. */
|
||||
UP = 2,
|
||||
/** uses the average of the two neighboring pixels (left and above) to predict the value of a pixel */
|
||||
AVERAGE = 3,
|
||||
/** computes a simple linear function of the three neighboring pixels (left, above, upper left), then chooses as predictor the neighboring pixel closest to the computed value. */
|
||||
PATH = 4
|
||||
}
|
||||
/**
|
||||
* Color type is a single-byte integer that describes the interpretation of the image data.
|
||||
* Color type codes represent sums of the following values:
|
||||
*
|
||||
* 1 (palette used), 2 (color used), and 4 (alpha channel used).
|
||||
*/
|
||||
export declare enum PNGColorType {
|
||||
GRAYSCALE = 0,
|
||||
COLOR = 2,
|
||||
GRAYSCALE_ALPHA = 4,
|
||||
COLOR_ALPHA = 6
|
||||
}
|
||||
//# sourceMappingURL=constants.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,aAAa;IACvB,IAAI,KAAK;IACT,yCAAyC;IACzC,IAAI,IAAI;IACR,mHAAmH;IACnH,GAAG,IAAI;IACP,uKAAuK;IACvK,EAAE,IAAI;IACN,sGAAsG;IACtG,OAAO,IAAI;IACX,kLAAkL;IAClL,IAAI,IAAI;CACT;AAED;;;;;GAKG;AACH,oBAAY,YAAY;IACtB,SAAS,IAAI;IACb,KAAK,IAAI;IACT,eAAe,IAAI;IACnB,WAAW,IAAI;CAChB"}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Filter method is a single-byte integer that indicates the preprocessing method applied to the image data before compression.
|
||||
*/
|
||||
export var PNGFilterType;
|
||||
(function (PNGFilterType) {
|
||||
PNGFilterType[PNGFilterType["AUTO"] = -1] = "AUTO";
|
||||
/** scanline is transmitted unmodified */
|
||||
PNGFilterType[PNGFilterType["NONE"] = 0] = "NONE";
|
||||
/** filter transmits the difference between each byte and the value of the corresponding byte of the prior pixel */
|
||||
PNGFilterType[PNGFilterType["SUB"] = 1] = "SUB";
|
||||
/** The Up() filter is just like the Sub() filter except that the pixel immediately above the current pixel, rather than just to its left, is used as the predictor. */
|
||||
PNGFilterType[PNGFilterType["UP"] = 2] = "UP";
|
||||
/** uses the average of the two neighboring pixels (left and above) to predict the value of a pixel */
|
||||
PNGFilterType[PNGFilterType["AVERAGE"] = 3] = "AVERAGE";
|
||||
/** computes a simple linear function of the three neighboring pixels (left, above, upper left), then chooses as predictor the neighboring pixel closest to the computed value. */
|
||||
PNGFilterType[PNGFilterType["PATH"] = 4] = "PATH";
|
||||
})(PNGFilterType || (PNGFilterType = {}));
|
||||
/**
|
||||
* Color type is a single-byte integer that describes the interpretation of the image data.
|
||||
* Color type codes represent sums of the following values:
|
||||
*
|
||||
* 1 (palette used), 2 (color used), and 4 (alpha channel used).
|
||||
*/
|
||||
export var PNGColorType;
|
||||
(function (PNGColorType) {
|
||||
PNGColorType[PNGColorType["GRAYSCALE"] = 0] = "GRAYSCALE";
|
||||
PNGColorType[PNGColorType["COLOR"] = 2] = "COLOR";
|
||||
PNGColorType[PNGColorType["GRAYSCALE_ALPHA"] = 4] = "GRAYSCALE_ALPHA";
|
||||
PNGColorType[PNGColorType["COLOR_ALPHA"] = 6] = "COLOR_ALPHA";
|
||||
})(PNGColorType || (PNGColorType = {}));
|
||||
//# sourceMappingURL=constants.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,aAYX;AAZD,WAAY,aAAa;IACvB,kDAAS,CAAA;IACT,yCAAyC;IACzC,iDAAQ,CAAA;IACR,mHAAmH;IACnH,+CAAO,CAAA;IACP,uKAAuK;IACvK,6CAAM,CAAA;IACN,sGAAsG;IACtG,uDAAW,CAAA;IACX,kLAAkL;IAClL,iDAAQ,CAAA;AACV,CAAC,EAZW,aAAa,KAAb,aAAa,QAYxB;AAED;;;;;GAKG;AACH,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,yDAAa,CAAA;IACb,iDAAS,CAAA;IACT,qEAAmB,CAAA;IACnB,6DAAe,CAAA;AACjB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB"}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import { PNGOptions as PNGJSOptions } from "pngjs";
|
||||
import { PNGFilterType, PNGColorType } from "./constants.js";
|
||||
export type { PNGOptions as PNGJSOptions } from "pngjs";
|
||||
export type PNGOptions = Omit<PNGJSOptions, "filterType" | "colorType" | "inputColorType"> & {
|
||||
filterType?: PNGFilterType;
|
||||
colorType?: PNGColorType;
|
||||
inputColorType?: PNGColorType;
|
||||
};
|
||||
export interface DecodePngOptions {
|
||||
checkCRC?: boolean | undefined;
|
||||
skipRescale?: boolean | undefined;
|
||||
}
|
||||
export * from "./constants.js";
|
||||
export default function png(): {
|
||||
mime: "image/png";
|
||||
hasAlpha: true;
|
||||
encode: (bitmap: import("@jimp/types").Bitmap, { deflateLevel, deflateStrategy, filterType, colorType, inputHasAlpha, ...options }?: PNGOptions) => Buffer;
|
||||
decode: (data: Buffer, options?: DecodePngOptions) => {
|
||||
data: Buffer;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,UAAU,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE7D,YAAY,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,YAAY,EACZ,YAAY,GAAG,WAAW,GAAG,gBAAgB,CAC9C,GAAG;IACF,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACnC;AAED,cAAc,gBAAgB,CAAC;AAE/B,MAAM,CAAC,OAAO,UAAU,GAAG;;;yIAalB,UAAU;qCAuBU,gBAAgB;;;;;EAU5C"}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import { PNG } from "pngjs";
|
||||
import { PNGFilterType, PNGColorType } from "./constants.js";
|
||||
export * from "./constants.js";
|
||||
export default function png() {
|
||||
return {
|
||||
mime: "image/png",
|
||||
hasAlpha: true,
|
||||
encode: (bitmap, { deflateLevel = 9, deflateStrategy = 3, filterType = PNGFilterType.AUTO, colorType, inputHasAlpha = true, ...options } = {}) => {
|
||||
const png = new PNG({
|
||||
width: bitmap.width,
|
||||
height: bitmap.height,
|
||||
});
|
||||
png.data = bitmap.data;
|
||||
return PNG.sync.write(png, {
|
||||
...options,
|
||||
deflateLevel,
|
||||
deflateStrategy,
|
||||
filterType,
|
||||
colorType: typeof colorType !== "undefined"
|
||||
? colorType
|
||||
: inputHasAlpha
|
||||
? PNGColorType.COLOR_ALPHA
|
||||
: PNGColorType.COLOR,
|
||||
inputHasAlpha,
|
||||
});
|
||||
},
|
||||
decode: (data, options) => {
|
||||
const result = PNG.sync.read(data, options);
|
||||
return {
|
||||
data: result.data,
|
||||
width: result.width,
|
||||
height: result.height,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAA8B,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAiB7D,cAAc,gBAAgB,CAAC;AAE/B,MAAM,CAAC,OAAO,UAAU,GAAG;IACzB,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,CACN,MAAM,EACN,EACE,YAAY,GAAG,CAAC,EAChB,eAAe,GAAG,CAAC,EACnB,UAAU,GAAG,aAAa,CAAC,IAAI,EAC/B,SAAS,EACT,aAAa,GAAG,IAAI,EACpB,GAAG,OAAO,KACI,EAAE,EAClB,EAAE;YACF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;gBAClB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC,CAAC;YAEH,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;YAEvB,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBACzB,GAAG,OAAO;gBACV,YAAY;gBACZ,eAAe;gBACf,UAAU;gBACV,SAAS,EACP,OAAO,SAAS,KAAK,WAAW;oBAC9B,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,aAAa;wBACb,CAAC,CAAC,YAAY,CAAC,WAAW;wBAC1B,CAAC,CAAC,YAAY,CAAC,KAAK;gBAC1B,aAAa;aACd,CAAC,CAAC;QACL,CAAC;QACD,MAAM,EAAE,CAAC,IAAI,EAAE,OAA0B,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAE5C,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC;QACJ,CAAC;KAC4B,CAAC;AAClC,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
Reference in new issue
Block a user