Initial commit

This commit is contained in:
robert committed 2025-05-30 18:13:30 +08:00
commit e49726988c
5445 files changed
+1089914

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { JimpClass } from "@jimp/types";
import { z } from "zod";
declare const FlipOptionsSchema: z.ZodObject<{
/** if true the image will be flipped horizontally */
horizontal: z.ZodOptional<z.ZodBoolean>;
/** if true the image will be flipped vertically */
vertical: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
horizontal?: boolean | undefined;
vertical?: boolean | undefined;
}, {
horizontal?: boolean | undefined;
vertical?: boolean | undefined;
}>;
export type FlipOptions = z.infer<typeof FlipOptionsSchema>;
export declare const methods: {
/**
* Flip the image.
* @param horizontal a Boolean, if true the image will be flipped horizontally
* @param vertical a Boolean, if true the image will be flipped vertically
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.flip(true, false);
* ```
*/
flip<I extends JimpClass>(image: I, options: FlipOptions): I;
};
export {};
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,iBAAiB;IACrB,qDAAqD;;IAErD,mDAAmD;;;;;;;;EAEnD,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;;OAYG;SACE,CAAC,SAAS,SAAS,SAAS,CAAC,WAAW,WAAW;CAiBzD,CAAC"}
+39
View File
@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.methods = void 0;
const zod_1 = require("zod");
const FlipOptionsSchema = zod_1.z.object({
/** if true the image will be flipped horizontally */
horizontal: zod_1.z.boolean().optional(),
/** if true the image will be flipped vertically */
vertical: zod_1.z.boolean().optional(),
});
exports.methods = {
/**
* Flip the image.
* @param horizontal a Boolean, if true the image will be flipped horizontally
* @param vertical a Boolean, if true the image will be flipped vertically
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.flip(true, false);
* ```
*/
flip(image, options) {
const { horizontal, vertical } = FlipOptionsSchema.parse(options);
const bitmap = Buffer.alloc(image.bitmap.data.length);
image.scan((x, y, idx) => {
const _x = horizontal ? image.bitmap.width - 1 - x : x;
const _y = vertical ? image.bitmap.height - 1 - y : y;
const _idx = (image.bitmap.width * _y + _x) << 2;
const data = image.bitmap.data.readUInt32BE(idx);
bitmap.writeUInt32BE(data, _idx);
});
image.bitmap.data = Buffer.from(bitmap);
return image;
},
};
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,6BAAwB;AAExB,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,qDAAqD;IACrD,UAAU,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC,mDAAmD;IACnD,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAIU,QAAA,OAAO,GAAG;IACrB;;;;;;;;;;;;OAYG;IACH,IAAI,CAAsB,KAAQ,EAAE,OAAoB;QACtD,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEtD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;YACvB,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACvD,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YACjD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAEjD,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAExC,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
+3
View File
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
+33
View File
@@ -0,0 +1,33 @@
import { JimpClass } from "@jimp/types";
import { z } from "zod";
declare const FlipOptionsSchema: z.ZodObject<{
/** if true the image will be flipped horizontally */
horizontal: z.ZodOptional<z.ZodBoolean>;
/** if true the image will be flipped vertically */
vertical: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
horizontal?: boolean | undefined;
vertical?: boolean | undefined;
}, {
horizontal?: boolean | undefined;
vertical?: boolean | undefined;
}>;
export type FlipOptions = z.infer<typeof FlipOptionsSchema>;
export declare const methods: {
/**
* Flip the image.
* @param horizontal a Boolean, if true the image will be flipped horizontally
* @param vertical a Boolean, if true the image will be flipped vertically
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.flip(true, false);
* ```
*/
flip<I extends JimpClass>(image: I, options: FlipOptions): I;
};
export {};
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,iBAAiB;IACrB,qDAAqD;;IAErD,mDAAmD;;;;;;;;EAEnD,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;;OAYG;SACE,CAAC,SAAS,SAAS,SAAS,CAAC,WAAW,WAAW;CAiBzD,CAAC"}
+36
View File
@@ -0,0 +1,36 @@
import { z } from "zod";
const FlipOptionsSchema = z.object({
/** if true the image will be flipped horizontally */
horizontal: z.boolean().optional(),
/** if true the image will be flipped vertically */
vertical: z.boolean().optional(),
});
export const methods = {
/**
* Flip the image.
* @param horizontal a Boolean, if true the image will be flipped horizontally
* @param vertical a Boolean, if true the image will be flipped vertically
* @example
* ```ts
* import { Jimp } from "jimp";
*
* const image = await Jimp.read("test/image.png");
*
* image.flip(true, false);
* ```
*/
flip(image, options) {
const { horizontal, vertical } = FlipOptionsSchema.parse(options);
const bitmap = Buffer.alloc(image.bitmap.data.length);
image.scan((x, y, idx) => {
const _x = horizontal ? image.bitmap.width - 1 - x : x;
const _y = vertical ? image.bitmap.height - 1 - y : y;
const _idx = (image.bitmap.width * _y + _x) << 2;
const data = image.bitmap.data.readUInt32BE(idx);
bitmap.writeUInt32BE(data, _idx);
});
image.bitmap.data = Buffer.from(bitmap);
return image;
},
};
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK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