├── .all-contributorsrc ├── .autorc ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── actions │ ├── build-cache │ │ └── action.yml │ └── install-deps │ │ └── action.yml ├── deploy-preview.yml ├── deploy-website.yml ├── pull_request_template.md └── workflows │ ├── build.yml │ └── deploy.yml ├── .gitignore ├── .ncurc.json ├── .prettierIgnore ├── .vscode └── settings.json ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── TODO.md ├── images ├── GIgFDCFbAAA0zlg.png └── discord.png ├── lerna.json ├── package.json ├── packages ├── config-eslint │ ├── base.js │ └── package.json ├── config-typescript │ ├── base.json │ └── package.json ├── config-vitest │ ├── browser.mjs │ ├── package.json │ └── tsconfig.json ├── core │ ├── CHANGELOG.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── utils │ │ │ ├── composite-modes.ts │ │ │ ├── composite.ts │ │ │ ├── constants.ts │ │ │ ├── exif-parser.d.ts │ │ │ ├── image-bitmap.ts │ │ │ └── mime.ts │ └── tsconfig.json ├── diff │ ├── CHANGELOG.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ └── tsconfig.json ├── docs │ ├── .gitignore │ ├── README.md │ ├── astro.config.mjs │ ├── package.json │ ├── public │ │ ├── dice.png │ │ ├── favicon.svg │ │ └── tree.webp │ ├── src │ │ ├── assets │ │ │ ├── houston.webp │ │ │ └── image.png │ │ ├── components │ │ │ ├── grayscale-example.tsx │ │ │ └── webp-example.tsx │ │ ├── content │ │ │ ├── config.ts │ │ │ └── docs │ │ │ │ ├── guides │ │ │ │ ├── browser.mdx │ │ │ │ ├── custom-jimp.mdx │ │ │ │ ├── getting-started.mdx │ │ │ │ ├── migrate-to-v1.mdx │ │ │ │ ├── webp.mdx │ │ │ │ └── writing-plugins.mdx │ │ │ │ ├── index.mdx │ │ │ │ └── reference │ │ │ │ └── example.md │ │ ├── env.d.ts │ │ ├── typedoc-plugin.js │ │ └── typedoc-zod-extended.js │ └── tsconfig.json ├── file-ops │ ├── CHANGELOG.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── index-browser.mts │ │ └── index.ts │ └── tsconfig.json ├── jimp │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── rollup.config.js │ ├── scripts │ │ └── generate-dts-bundle.js │ ├── src │ │ ├── __image_snapshots__ │ │ │ ├── composite-node-test-ts-composite-can-apply-more-than-one-color-transformation-1-snap.png │ │ │ ├── composite-node-test-ts-composite-should-handle-edges-correctly-1-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-1-1-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-1-2-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-2-1-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-2-2-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-3-1-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-3-2-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-4-1-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-4-2-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-5-1-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-5-2-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-6-1-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-6-2-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-7-1-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-7-2-snap.png │ │ │ ├── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-8-1-snap.png │ │ │ └── exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-8-2-snap.png │ │ ├── __snapshots__ │ │ │ ├── callbacks.test.ts.snap │ │ │ └── scan.test.ts.snap │ │ ├── callbacks.test.ts │ │ ├── canvas.browser.test.ts │ │ ├── composite.node.test.ts │ │ ├── exif.node.test.ts │ │ ├── fonts.ts │ │ ├── images │ │ │ └── exif-orientation │ │ │ │ ├── Landscape_1.jpg │ │ │ │ ├── Landscape_2.jpg │ │ │ │ ├── Landscape_3.jpg │ │ │ │ ├── Landscape_4.jpg │ │ │ │ ├── Landscape_5.jpg │ │ │ │ ├── Landscape_6.jpg │ │ │ │ ├── Landscape_7.jpg │ │ │ │ ├── Landscape_8.jpg │ │ │ │ ├── Portrait_1.jpg │ │ │ │ ├── Portrait_2.jpg │ │ │ │ ├── Portrait_3.jpg │ │ │ │ ├── Portrait_4.jpg │ │ │ │ ├── Portrait_5.jpg │ │ │ │ ├── Portrait_6.jpg │ │ │ │ ├── Portrait_7.jpg │ │ │ │ ├── Portrait_8.jpg │ │ │ │ ├── README.markdown │ │ │ │ └── VERSION │ │ ├── index-browser.mts │ │ ├── index.ts │ │ ├── jimp.test.ts │ │ └── scan.test.ts │ ├── tsconfig.docs.json │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── test-utils │ ├── CHANGELOG.md │ ├── eslint.config.mjs │ ├── images │ │ ├── animated.gif │ │ ├── cops.jpg │ │ ├── dice.png │ │ ├── fillbytes.jpg │ │ ├── flower.gif │ │ ├── hands.jpg │ │ ├── hands_mx200_rp255.jpg │ │ ├── mask.png │ │ ├── panoramic.jpg │ │ ├── rgb.tiff │ │ ├── windows95.bmp │ │ └── windows95.png │ ├── package.json │ ├── src │ │ ├── image-snapshot.ts │ │ └── index.ts │ └── tsconfig.json ├── types │ ├── CHANGELOG.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json └── utils │ ├── CHANGELOG.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ ├── index.test.ts │ └── index.ts │ └── tsconfig.json ├── plugins ├── js-bmp │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── images │ │ │ ├── windows95.bmp │ │ │ └── windows95.png │ │ ├── index.node.test.ts │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── js-gif │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── js-jpeg │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── js-png │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __image_snapshots__ │ │ │ └── index-node-test-ts-png-should-use-png-options-1-snap.png │ │ ├── constants.ts │ │ ├── index.node.test.ts │ │ ├── index.test.ts │ │ ├── index.ts │ │ └── output.png │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── js-tiff │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-blit │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __image_snapshots__ │ │ │ ├── index-node-test-ts-blit-over-image-blit-alpha-1-snap.png │ │ │ ├── index-node-test-ts-blit-over-image-uses-src-params-correctly-1-snap.png │ │ │ ├── index-node-test-ts-blit-over-image-uses-src-params-correctly-2-snap.png │ │ │ └── index-node-test-ts-blit-over-image-uses-src-params-correctly-3-snap.png │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── images │ │ │ ├── blit-alpha.png │ │ │ ├── cat-results │ │ │ │ ├── large-cat.png │ │ │ │ ├── medium-cat.png │ │ │ │ └── small-cat.png │ │ │ ├── cat_butt.png │ │ │ ├── cat_fuzz.png │ │ │ └── cat_head.png │ │ ├── index.node.test.ts │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-blur │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __image_snapshots__ │ │ │ └── index-node-test-ts-has-alpha-image-with-alpha-1-snap.png │ │ ├── blur-tables.ts │ │ ├── index.node.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-circle │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-color │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __image_snapshots__ │ │ │ ├── birghtness-node-test-ts-brightness-3-x-3-box-blur-matrix-using-convolute-1-snap.png │ │ │ ├── convolution-node-test-ts-convolution-3-x-3-box-blur-matrix-using-convolute-1-snap.png │ │ │ └── convolution-node-test-ts-convolution-new-pixel-value-is-greater-than-255-1-snap.png │ │ ├── __snapshots__ │ │ │ ├── convolution.test.ts.snap │ │ │ ├── index.test.ts.snap │ │ │ └── normalize.test.ts.snap │ │ ├── birghtness.node.test.ts │ │ ├── convolution.node.test.ts │ │ ├── convolution.test.ts │ │ ├── images │ │ │ ├── qr.jpg │ │ │ └── tiles.jpg │ │ ├── index.test.ts │ │ ├── index.ts │ │ └── normalize.test.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-contain │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-cover │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-crop │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ ├── autocrop.test.ts.snap │ │ │ └── crop.test.ts.snap │ │ ├── autocrop.test.ts │ │ ├── crop.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-displace │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── plugin-dither │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── plugin-fisheye │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-flip │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-hash │ ├── CHANGELOG.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── index.test.ts │ │ ├── index.ts │ │ └── phash.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-mask │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-print │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── fonts │ │ └── open-sans │ │ │ ├── Apache License.txt │ │ │ ├── open-sans-10-black │ │ │ ├── open-sans-10-black.fnt │ │ │ └── open-sans-10-black.png │ │ │ ├── open-sans-12-black │ │ │ ├── open-sans-12-black.fnt │ │ │ └── open-sans-12-black.png │ │ │ ├── open-sans-128-black │ │ │ ├── open-sans-128-black.fnt │ │ │ └── open-sans-128-black.png │ │ │ ├── open-sans-128-white │ │ │ ├── open-sans-128-white.fnt │ │ │ └── open-sans-128-white.png │ │ │ ├── open-sans-14-black │ │ │ ├── open-sans-14-black.fnt │ │ │ └── open-sans-14-black.png │ │ │ ├── open-sans-16-black │ │ │ ├── open-sans-16-black.fnt │ │ │ └── open-sans-16-black.png │ │ │ ├── open-sans-16-white │ │ │ ├── open-sans-16-white.fnt │ │ │ └── open-sans-16-white.png │ │ │ ├── open-sans-32-black │ │ │ ├── open-sans-32-black.fnt │ │ │ └── open-sans-32-black.png │ │ │ ├── open-sans-32-white │ │ │ ├── open-sans-32-white.fnt │ │ │ └── open-sans-32-white.png │ │ │ ├── open-sans-64-black │ │ │ ├── open-sans-64-black.fnt │ │ │ └── open-sans-64-black.png │ │ │ ├── open-sans-64-white │ │ │ ├── open-sans-64-white.fnt │ │ │ └── open-sans-64-white.png │ │ │ ├── open-sans-8-black │ │ │ ├── open-sans-8-black.fnt │ │ │ └── open-sans-8-black.png │ │ │ └── open-sans-8-white │ │ │ ├── open-sans-8-white.fnt │ │ │ └── open-sans-8-white.png │ ├── package.json │ ├── src │ │ ├── __image_snapshots__ │ │ │ ├── index-node-test-ts-write-text-over-image-bottom-align-text-when-passing-object-with-alignment-y-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-bottom-align-text-when-passing-object-with-alignment-y-offset-y-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-center-align-text-when-passing-object-with-alignment-x-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-exposes-print-y-position-in-cb-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-can-print-numbers-too-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-loads-font-from-url-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-16-black-bitmap-font-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-16-black-bitmap-font-positioned-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-16-white-bitmap-font-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-32-black-bitmap-font-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-32-white-bitmap-font-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-64-black-bitmap-font-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-64-white-bitmap-font-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-8-black-bitmap-font-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-preset-sans-8-white-bitmap-font-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-jimp-renders-for-unknown-characters-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-left-align-text-by-default-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-left-align-text-by-default-when-passing-object-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-left-align-text-when-passing-object-with-alignment-x-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-max-width-works-without-spaces-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-middle-align-text-when-passing-object-with-alignment-y-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-middle-align-text-when-passing-object-with-alignment-y-can-offset-y-1-snap.png │ │ │ ├── index-node-test-ts-write-text-over-image-right-align-text-when-passing-object-with-alignment-x-1-snap.png │ │ │ └── index-node-test-ts-write-text-over-image-text-with-newlines-default-alignment-1-snap.png │ │ ├── dirname-cjs.cts │ │ ├── dirname.ts │ │ ├── fonts.ts │ │ ├── index.node.test.ts │ │ ├── index.ts │ │ ├── load-bitmap-font.ts │ │ ├── load-font.ts │ │ ├── measure-text.ts │ │ ├── types.ts │ │ └── types │ │ │ ├── parse-bmfont-ascii.d.ts │ │ │ ├── parse-bmfont-binary.d.ts │ │ │ └── parse-bmfont-xml.d.ts │ └── tsconfig.json ├── plugin-quantize │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __image_snapshots__ │ │ │ └── index-node-test-ts-quantize-defines-default-threshold-for-lighter-backgrounds-1-snap.png │ │ ├── images │ │ │ └── colorful.png │ │ ├── index.node.test.ts │ │ └── index.ts │ └── tsconfig.json ├── plugin-resize │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── constants.ts │ │ ├── index.test.ts │ │ ├── index.ts │ │ └── modules │ │ │ ├── resize.ts │ │ │ └── resize2.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-rotate │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-shadow │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── plugin-threshold │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ ├── __image_snapshots__ │ │ │ └── index-test-ts-src-index-test-ts-threshold-defines-default-threshold-for-lighter-backgrounds-1-snap.png │ │ ├── index.test.ts │ │ └── index.ts │ ├── tsconfig.json │ └── vitest.config.browser.mjs ├── wasm-avif │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── wasm-jpeg │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── wasm-png │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json └── wasm-webp │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── src │ ├── images │ │ └── test.webp │ └── index.ts │ └── tsconfig.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── refactor.js ├── test.js ├── tsconfig.json ├── turbo.json └── turbo └── generators ├── config.ts └── templates └── package ├── eslint.config.mjs ├── package.json ├── src ├── index.test.ts └── index.ts └── tsconfig.json /.autorc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "npm", 4 | "released", 5 | "first-time-contributor", 6 | "all-contributors" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: hipstersmoothie 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Expected Behavior 4 | 5 | 6 | 7 | # Current Behavior 8 | 9 | 10 | 11 | # Failure Information (for bugs) 12 | 13 | 14 | 15 | ## Steps to Reproduce 16 | 17 | 24 | 25 | ## Context 26 | 27 | 28 | 29 | - Jimp Version: 30 | - Operating System: 31 | - Node version: 32 | 33 | ## Failure Logs 34 | 35 | 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | 7 | 8 | # Expected Behavior 9 | 10 | 11 | 12 | # Current Behavior 13 | 14 | 15 | 16 | # Failure Information (for bugs) 17 | 18 | 19 | 20 | ## Steps to Reproduce 21 | 22 | 29 | 30 | **Screenshots** 31 | 32 | 33 | 34 | ## Context 35 | 36 | 37 | 38 | - Jimp Version: 39 | - Operating System: 40 | - Node version: 41 | 42 | ## Failure Logs 43 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | --- 5 | 6 | **Is your feature request related to a problem? Please describe.** 7 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 8 | 9 | **Describe the solution you'd like** 10 | A clear and concise description of what you want to happen. 11 | 12 | **Describe alternatives you've considered** 13 | A clear and concise description of any alternative solutions or features you've considered. 14 | 15 | **Additional context** 16 | Add any other context or screenshots about the feature request here. 17 | -------------------------------------------------------------------------------- /.github/actions/build-cache/action.yml: -------------------------------------------------------------------------------- 1 | name: "Build Cache" 2 | description: build cache 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: build cache 8 | uses: actions/cache@v3 9 | with: 10 | path: | 11 | packages/*/dist 12 | plugins/*/dist 13 | key: ${{ github.run_id }} 14 | restore-keys: ${{ github.run_id }} 15 | -------------------------------------------------------------------------------- /.github/actions/install-deps/action.yml: -------------------------------------------------------------------------------- 1 | name: "Setup" 2 | description: Setup action 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: Setup Node 8 | uses: actions/setup-node@v4 9 | with: 10 | node-version: 18 11 | 12 | - uses: pnpm/action-setup@v3 13 | with: 14 | version: 8.9.0 15 | run_install: false 16 | 17 | - name: Get pnpm store directory 18 | shell: bash 19 | run: | 20 | echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV 21 | 22 | - uses: actions/cache@v4 23 | name: Setup pnpm cache 24 | with: 25 | path: ${{ env.STORE_PATH }} 26 | key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} 27 | restore-keys: | 28 | ${{ runner.os }}-pnpm-store- 29 | 30 | - name: Install dependencies 31 | shell: bash 32 | run: pnpm install 33 | -------------------------------------------------------------------------------- /.github/deploy-preview.yml: -------------------------------------------------------------------------------- 1 | name: Deploy PR previews 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - opened 7 | - reopened 8 | - synchronize 9 | - closed 10 | 11 | concurrency: preview-${{ github.ref }} 12 | 13 | jobs: 14 | deploy-preview: 15 | runs-on: ubuntu-20.04 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v3 19 | 20 | - uses: ./.github/actions/install-deps 21 | 22 | - name: Build with Astro 23 | run: | 24 | pnpm astro build \ 25 | --site "${{ steps.pages.outputs.origin }}" \ 26 | --base "${{ steps.pages.outputs.base_path }}" 27 | working-directory: packages/docs 28 | 29 | - name: Deploy preview 30 | uses: rossjrw/pr-preview-action@v1 31 | with: 32 | source-dir: packages/docs/dist 33 | -------------------------------------------------------------------------------- /.github/deploy-website.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Website 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [main] 7 | 8 | permissions: 9 | contents: read 10 | pages: write 11 | id-token: write 12 | 13 | concurrency: 14 | group: "pages" 15 | cancel-in-progress: false 16 | 17 | jobs: 18 | build: 19 | name: Build 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v4 24 | 25 | - uses: ./.github/actions/install-deps 26 | 27 | - name: Setup Pages 28 | id: pages 29 | uses: actions/configure-pages@v5 30 | 31 | - name: Build with Astro 32 | run: | 33 | pnpm astro build \ 34 | --site "${{ steps.pages.outputs.origin }}" \ 35 | --base "${{ steps.pages.outputs.base_path }}" 36 | working-directory: packages/docs 37 | 38 | - name: Upload artifact 39 | uses: actions/upload-pages-artifact@v3 40 | with: 41 | path: packages/docs/dist 42 | 43 | deploy: 44 | environment: 45 | name: github-pages 46 | url: ${{ steps.deployment.outputs.page_url }} 47 | needs: build 48 | runs-on: ubuntu-latest 49 | name: Deploy 50 | steps: 51 | - name: Deploy to GitHub Pages 52 | id: deployment 53 | uses: actions/deploy-pages@v4 54 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # What's Changing and Why 2 | 3 | ## What else might be affected 4 | 5 | ## Tasks 6 | 7 | - [ ] Add tests 8 | - [ ] Update Documentation 9 | - [ ] Update `jimp.d.ts` 10 | - [ ] Add [SemVer](https://semver.org/) Label 11 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: deploy 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | # Enabled permissions on GITHUB_TOKEN 9 | permissions: 10 | # To be able to push to the repo 11 | contents: write 12 | # To update the pr description with canary info 13 | pull-requests: write 14 | # For pr-check to create a status 15 | statuses: write 16 | # Needed to create PR statuses/checks 17 | checks: write 18 | # To post comments on PRs 19 | issues: write 20 | # Astro deploy 21 | pages: write 22 | id-token: write 23 | 24 | jobs: 25 | build: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - uses: actions/checkout@v3 29 | - uses: ./.github/actions/install-deps 30 | - run: pnpm build 31 | - run: pnpm build 32 | working-directory: packages/docs 33 | - name: Upload Pages Artifact 34 | uses: actions/upload-pages-artifact@v3 35 | with: 36 | path: packages/docs/dist/ 37 | 38 | deploy: 39 | needs: build 40 | runs-on: ubuntu-latest 41 | environment: 42 | name: github-pages 43 | url: ${{ steps.deployment.outputs.page_url }} 44 | steps: 45 | - name: Deploy to GitHub Pages 46 | id: deployment 47 | uses: actions/deploy-pages@v4 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | .env 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | packages/docs/src/content/docs/api/** 12 | 13 | # Directory for instrumented libs generated by jscoverage/JSCover 14 | lib-cov 15 | 16 | # Coverage directory used by tools like istanbul 17 | coverage 18 | .nyc_output 19 | .tshy 20 | .tshy-build 21 | .turbo 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # node-waf configuration 27 | .lock-wscript 28 | 29 | # Compiled binary addons (http://nodejs.org/api/addons.html) 30 | build/Release 31 | 32 | # Dependency directory 33 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 34 | node_modules 35 | 36 | # IDE files 37 | .project 38 | .idea 39 | *.iml 40 | 41 | # Test output images 42 | /test/output/*.png 43 | /test/output/*.jpg 44 | /test/output/*.bmp 45 | 46 | .DS_Store 47 | 48 | package-lock.json 49 | 50 | # Browser Version 51 | **/browser/lib/*.js 52 | # ES5 Version 53 | dist/ 54 | # ESM Version 55 | es/ 56 | jimp.js.* 57 | repro-playground.js 58 | **/src/package.json -------------------------------------------------------------------------------- /.ncurc.json: -------------------------------------------------------------------------------- 1 | { 2 | "reject": [ 3 | // These deps are esm only 4 | "pixelmatch", 5 | "mime", 6 | "@types/mime", 7 | "file-type", 8 | // We support node 18 and above 9 | "@types/node" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /.prettierIgnore: -------------------------------------------------------------------------------- 1 | browser/lib/* -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "prettier.prettierPath": "./node_modules/prettier/index.cjs" 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Oliver Moran 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | ## Guides 2 | 3 | - [ ] Custom Jimp 4 | - [ ] Authoring Plugins 5 | - [] Using in Browser 6 | - [ ] Worker 7 | -------------------------------------------------------------------------------- /images/GIgFDCFbAAA0zlg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/images/GIgFDCFbAAA0zlg.png -------------------------------------------------------------------------------- /images/discord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/images/discord.png -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "^7.1.4", 3 | "npmClient": "pnpm", 4 | "registry": "https://registry.npmjs.org/", 5 | "version": "1.6.0", 6 | "packages": [ 7 | "packages/*", 8 | "plugins/*" 9 | ] 10 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jimp-monorepo", 3 | "private": true, 4 | "packageManager": "pnpm@9.9.0", 5 | "description": "The jimp monorepo.", 6 | "repository": "jimp-dev/jimp", 7 | "engines": { 8 | "node": ">=18" 9 | }, 10 | "author": "Andrew Lisowski ", 11 | "scripts": { 12 | "build": "turbo run build build:browser --filter=!@jimp/docs", 13 | "dev": "turbo run dev", 14 | "lint": "turbo run lint", 15 | "test": "turbo run test -- --watch=false", 16 | "test:browser": "turbo run test:browser -- --watch=false", 17 | "clean": "turbo run clean && rm -rf node_modules .turbo", 18 | "format": "prettier --write \"**/*.{ts,tsx,md}\"", 19 | "release": "pnpm build && auto shipit", 20 | "generate-package": "turbo gen package", 21 | "generate-plugin": "turbo gen plugin", 22 | "check-updates": "ncu --packageFile '{,*/**/}package.json'" 23 | }, 24 | "devDependencies": { 25 | "@auto-it/all-contributors": "^11.2.1", 26 | "@auto-it/first-time-contributor": "^11.2.1", 27 | "@auto-it/released": "^11.2.1", 28 | "@jimp/config-eslint": "workspace:*", 29 | "@jimp/config-typescript": "workspace:*", 30 | "@turbo/gen": "^2.1.1", 31 | "auto": "^11.2.1", 32 | "npm-check-updates": "^17.1.1", 33 | "prettier": "^3.3.3", 34 | "turbo": "^2.1.1" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/config-eslint/base.js: -------------------------------------------------------------------------------- 1 | import js from "@eslint/js"; 2 | import eslintConfigPrettier from "eslint-config-prettier"; 3 | import turboPlugin from "eslint-plugin-turbo"; 4 | import tseslint from "typescript-eslint"; 5 | 6 | export default [ 7 | js.configs.recommended, 8 | eslintConfigPrettier, 9 | ...tseslint.configs.recommended, 10 | { 11 | ignores: [ 12 | // Ignore dotfiles 13 | ".*.js", 14 | "node_modules/", 15 | "dist/", 16 | "**/browser.js", 17 | ], 18 | }, 19 | { 20 | name: "eslint-config-turbo (recreated flat)", 21 | plugins: { 22 | turbo: { rules: turboPlugin.rules }, 23 | }, 24 | rules: { 25 | "turbo/no-undeclared-env-vars": "error", 26 | }, 27 | }, 28 | ]; 29 | -------------------------------------------------------------------------------- /packages/config-eslint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/config-eslint", 3 | "version": "1.6.0", 4 | "license": "MIT", 5 | "private": true, 6 | "main": "base.js", 7 | "type": "module", 8 | "scripts": { 9 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 10 | }, 11 | "devDependencies": { 12 | "eslint-config-prettier": "^9.1.0", 13 | "eslint-config-turbo": "^2.1.1", 14 | "typescript": "^5.5.4" 15 | }, 16 | "publishConfig": {}, 17 | "sideEffects": false, 18 | "dependencies": { 19 | "@eslint/js": "^9.9.1", 20 | "@types/eslint__js": "^8.42.3", 21 | "typescript-eslint": "^8.3.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/config-typescript/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "Default", 4 | "compilerOptions": { 5 | "declaration": true, 6 | "declarationMap": true, 7 | "esModuleInterop": true, 8 | "incremental": false, 9 | "isolatedModules": true, 10 | "sourceMap": true, 11 | "lib": ["es2022", "DOM", "DOM.Iterable"], 12 | "module": "NodeNext", 13 | "moduleDetection": "force", 14 | "moduleResolution": "NodeNext", 15 | "noUncheckedIndexedAccess": true, 16 | "resolveJsonModule": true, 17 | "skipLibCheck": true, 18 | "strict": true, 19 | "allowJs": true, 20 | "target": "ES2022" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/config-typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/config-typescript", 3 | "version": "1.6.0", 4 | "private": true, 5 | "license": "MIT", 6 | "publishConfig": { 7 | "access": "public" 8 | }, 9 | "sideEffects": false, 10 | "scripts": { 11 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/config-vitest/browser.mjs: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vitest/config"; 2 | import { createRequire } from "module"; 3 | import path from "path"; 4 | import { nodePolyfills } from "vite-plugin-node-polyfills"; 5 | 6 | const require = createRequire(import.meta.url); 7 | const imagesFolder = path.join( 8 | path.join(path.dirname(require.resolve("@jimp/test-utils")), "../../"), 9 | "images", 10 | ); 11 | 12 | export default defineConfig({ 13 | resolve: { 14 | alias: { 15 | pngjs: "pngjs/browser.js", 16 | }, 17 | }, 18 | test: { 19 | exclude: [ 20 | "**/.tshy-build", 21 | "**/.tshy", 22 | "**/*.node.test.ts", 23 | "**/node_modules/**", 24 | "**/dist/**", 25 | "**/cypress/**", 26 | "**/.{idea,git,cache,output,temp}/**", 27 | "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*", 28 | ], 29 | browser: { 30 | enabled: true, 31 | provider: "playwright", 32 | name: "chromium", 33 | headless: true, 34 | }, 35 | }, 36 | publicDir: imagesFolder, 37 | plugins: [ 38 | nodePolyfills({ 39 | globals: { 40 | Buffer: true, 41 | }, 42 | }), 43 | ], 44 | }); 45 | -------------------------------------------------------------------------------- /packages/config-vitest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/config-vitest", 3 | "version": "1.6.0", 4 | "private": true, 5 | "repository": "jimp-dev/jimp", 6 | "engines": { 7 | "node": ">=18" 8 | }, 9 | "scripts": { 10 | "dev": "tshy --watch", 11 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 12 | }, 13 | "author": "Andrew Lisowski ", 14 | "license": "MIT", 15 | "devDependencies": { 16 | "@jimp/config-typescript": "workspace:*", 17 | "@jimp/test-utils": "workspace:*", 18 | "eslint": "^9.9.1", 19 | "typescript": "^5.5.4", 20 | "vitest": "^2.0.5" 21 | }, 22 | "dependencies": { 23 | "@esbuild-plugins/node-globals-polyfill": "^0.2.3", 24 | "playwright": "^1.46.1", 25 | "vite-plugin-node-polyfills": "^0.22.0" 26 | }, 27 | "type": "module", 28 | "publishConfig": { 29 | "access": "public" 30 | }, 31 | "sideEffects": false 32 | } 33 | -------------------------------------------------------------------------------- /packages/config-vitest/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/core/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [ 3 | ...shared, 4 | { 5 | rules: { 6 | "@typescript-eslint/no-explicit-any": "off", 7 | }, 8 | }, 9 | ]; 10 | -------------------------------------------------------------------------------- /packages/core/src/utils/exif-parser.d.ts: -------------------------------------------------------------------------------- 1 | declare module "exif-parser" { 2 | export interface ExifData { 3 | tags?: { 4 | Orientation?: number; 5 | }; 6 | } 7 | 8 | function create(data: Buffer): { 9 | parse: () => ExifData; 10 | }; 11 | 12 | export { create }; 13 | } 14 | -------------------------------------------------------------------------------- /packages/core/src/utils/mime.ts: -------------------------------------------------------------------------------- 1 | // const mimeTypes = {}; 2 | 3 | // const findType = (extension: string) => 4 | // Object.entries(mimeTypes).find((type) => type[1].includes(extension)) || []; 5 | 6 | // export const addType = (mime: string, extensions: string[]) => { 7 | // mimeTypes[mime] = extensions; 8 | // }; 9 | 10 | // /** 11 | // * Lookup a mime type based on extension 12 | // * @param {string} path path to find extension for 13 | // * @returns {string} mime found mime type 14 | // */ 15 | // export const getType = (path: string) => { 16 | // const pathParts = path.split("/").slice(-1); 17 | // const extension = pathParts[pathParts.length - 1]?.split(".").pop(); 18 | 19 | // if (!extension) { 20 | // return null; 21 | // } 22 | 23 | // const type = findType(extension); 24 | 25 | // return type[0]; 26 | // }; 27 | 28 | // /** 29 | // * Return file extension associated with a mime type 30 | // * @param {string} type mime type to look up 31 | // * @returns {string} extension file extension 32 | // */ 33 | // export const getExtension = (type: string) => 34 | // (mimeTypes[type.toLowerCase()] || [])[0]; 35 | -------------------------------------------------------------------------------- /packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/diff/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.2 (Mon Sep 02 2024) 14 | 15 | #### 🐛 Bug Fix 16 | 17 | - Jimp.diff() to make real resize before image compare [#1311](https://github.com/jimp-dev/jimp/pull/1311) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | 19 | #### Authors: 1 20 | 21 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 22 | 23 | --- 24 | 25 | # v1.1.0 (Sun Sep 01 2024) 26 | 27 | #### ⚠️ Pushed to `main` 28 | 29 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 30 | 31 | #### Authors: 1 32 | 33 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 34 | 35 | --- 36 | 37 | # v1.0.3 (Sat Aug 31 2024) 38 | 39 | #### 🐛 Bug Fix 40 | 41 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 42 | 43 | #### ⚠️ Pushed to `main` 44 | 45 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 46 | 47 | #### Authors: 1 48 | 49 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 50 | 51 | --- 52 | 53 | # v1.0.2 (Sat Aug 31 2024) 54 | 55 | #### ⚠️ Pushed to `main` 56 | 57 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 58 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 59 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 60 | 61 | #### Authors: 1 62 | 63 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 64 | -------------------------------------------------------------------------------- /packages/diff/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /packages/diff/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/diff", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "test": "vitest", 11 | "build": "tshy", 12 | "dev": "tshy --watch", 13 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 14 | }, 15 | "author": "Andrew Lisowski ", 16 | "license": "MIT", 17 | "dependencies": { 18 | "@jimp/plugin-resize": "workspace:*", 19 | "@jimp/types": "workspace:*", 20 | "@jimp/utils": "workspace:*", 21 | "pixelmatch": "^5.3.0" 22 | }, 23 | "devDependencies": { 24 | "@jimp/config-eslint": "workspace:*", 25 | "@jimp/config-typescript": "workspace:*", 26 | "@jimp/core": "workspace:*", 27 | "@jimp/test-utils": "workspace:*", 28 | "@types/pixelmatch": "^5.2.6", 29 | "eslint": "^9.9.1", 30 | "tshy": "^3.0.2", 31 | "typescript": "^5.5.4", 32 | "vitest": "^2.0.5" 33 | }, 34 | "tshy": { 35 | "exclude": [ 36 | "**/*.test.ts" 37 | ], 38 | "exports": { 39 | "./package.json": "./package.json", 40 | ".": "./src/index.ts" 41 | } 42 | }, 43 | "exports": { 44 | "./package.json": "./package.json", 45 | ".": { 46 | "import": { 47 | "types": "./dist/esm/index.d.ts", 48 | "default": "./dist/esm/index.js" 49 | }, 50 | "require": { 51 | "types": "./dist/commonjs/index.d.ts", 52 | "default": "./dist/commonjs/index.js" 53 | } 54 | } 55 | }, 56 | "main": "./dist/commonjs/index.js", 57 | "types": "./dist/commonjs/index.d.ts", 58 | "type": "module", 59 | "publishConfig": { 60 | "access": "public" 61 | }, 62 | "sideEffects": false, 63 | "module": "./dist/esm/index.js" 64 | } 65 | -------------------------------------------------------------------------------- /packages/diff/src/__snapshots__/index.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`Compare image difference > images 0 and 1 1`] = ` 4 | Visualization: 5 | 6 | D▴▴▴ 7 | ▴3▴▴ 8 | ▴▴◇▴ 9 | ▴▴▴▩ 10 | 11 | Data: 12 | 13 | E8-E8-E8ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ 14 | FF-00-00ᶠᶠ EC-EC-ECᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ 15 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ EF-EF-EFᶠᶠ FF-00-00ᶠᶠ 16 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ F3-F3-F3ᶠᶠ 17 | `; 18 | 19 | exports[`Compare image difference > images 0 and 2 1`] = ` 20 | Visualization: 21 | 22 | DDDD 23 | 3333 24 | ◇◇◇◇ 25 | ▩▩▩▩ 26 | 27 | Data: 28 | 29 | E8-E8-E8ᶠᶠ E8-E8-E8ᶠᶠ E8-E8-E8ᶠᶠ E8-E8-E8ᶠᶠ 30 | EC-EC-ECᶠᶠ EC-EC-ECᶠᶠ EC-EC-ECᶠᶠ EC-EC-ECᶠᶠ 31 | EF-EF-EFᶠᶠ EF-EF-EFᶠᶠ EF-EF-EFᶠᶠ EF-EF-EFᶠᶠ 32 | F3-F3-F3ᶠᶠ F3-F3-F3ᶠᶠ F3-F3-F3ᶠᶠ F3-F3-F3ᶠᶠ 33 | `; 34 | 35 | exports[`Compare image difference > images 0 and 3 1`] = ` 36 | Visualization: 37 | 38 | DDDD 39 | 3333 40 | ◇◇◇◇ 41 | ▩▩▩▩ 42 | 43 | Data: 44 | 45 | E8-E8-E8ᶠᶠ E8-E8-E8ᶠᶠ E8-E8-E8ᶠᶠ E8-E8-E8ᶠᶠ 46 | EC-EC-ECᶠᶠ EC-EC-ECᶠᶠ EC-EC-ECᶠᶠ EC-EC-ECᶠᶠ 47 | EF-EF-EFᶠᶠ EF-EF-EFᶠᶠ EF-EF-EFᶠᶠ EF-EF-EFᶠᶠ 48 | F3-F3-F3ᶠᶠ F3-F3-F3ᶠᶠ F3-F3-F3ᶠᶠ F3-F3-F3ᶠᶠ 49 | `; 50 | -------------------------------------------------------------------------------- /packages/diff/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/docs/.gitignore: -------------------------------------------------------------------------------- 1 | # build output 2 | dist/ 3 | # generated types 4 | .astro/ 5 | 6 | # dependencies 7 | node_modules/ 8 | 9 | # logs 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | pnpm-debug.log* 14 | 15 | 16 | # environment variables 17 | .env 18 | .env.production 19 | 20 | # macOS-specific files 21 | .DS_Store 22 | -------------------------------------------------------------------------------- /packages/docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/docs", 3 | "private": true, 4 | "version": "1.6.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "astro dev", 8 | "start": "astro dev", 9 | "build": "rm -rf dist && astro check && astro build", 10 | "preview": "astro preview", 11 | "astro": "astro", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "dependencies": { 15 | "@astrojs/check": "^0.9.3", 16 | "@astrojs/react": "^3.6.2", 17 | "@astrojs/starlight": "^0.26.1", 18 | "@esbuild-plugins/node-globals-polyfill": "^0.2.3", 19 | "@jimp/core": "workspace:*", 20 | "@jimp/plugin-print": "workspace:*", 21 | "@jimp/wasm-webp": "workspace:*", 22 | "@types/react": "^18.3.5", 23 | "astro": "^4.15.1", 24 | "eslint": "^9.9.1", 25 | "jimp": "workspace:*", 26 | "react": "^18.3.1", 27 | "react-dom": "^18.3.1", 28 | "sharp": "^0.33.5", 29 | "starlight-typedoc": "^0.15.0", 30 | "typedoc": "^0.26.6", 31 | "typedoc-plugin-markdown": "4.2.6", 32 | "typedoc-plugin-zod": "^1.2.1", 33 | "typescript": "^5.5.4" 34 | }, 35 | "devDependencies": { 36 | "vite-plugin-node-polyfills": "^0.22.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/docs/public/dice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/docs/public/dice.png -------------------------------------------------------------------------------- /packages/docs/public/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/docs/public/tree.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/docs/public/tree.webp -------------------------------------------------------------------------------- /packages/docs/src/assets/houston.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/docs/src/assets/houston.webp -------------------------------------------------------------------------------- /packages/docs/src/assets/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/docs/src/assets/image.png -------------------------------------------------------------------------------- /packages/docs/src/content/config.ts: -------------------------------------------------------------------------------- 1 | import { defineCollection } from "astro:content"; 2 | import { docsSchema } from "@astrojs/starlight/schema"; 3 | 4 | export const collections = { 5 | docs: defineCollection({ schema: docsSchema() }), 6 | }; 7 | -------------------------------------------------------------------------------- /packages/docs/src/content/docs/guides/custom-jimp.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom Jimp 3 | description: How to create a custom Jimp 4 | --- 5 | 6 | If you don't want to use all the default plugins included in the `jimp` package, you can create a custom Jimp. 7 | 8 | ## Creating a custom Jimp 9 | 10 | To create a custom Jimp, you can use the `create` function from the `jimp` package. 11 | 12 | ```ts 13 | import { promises as fs } from "fs"; 14 | 15 | import { createJimp } from "@jimp/core"; 16 | import png from "@jimp/js-png"; 17 | import * as resize from "@jimp/plugin-resize"; 18 | 19 | const MyJimp = createJimp({ 20 | plugins: [resize.methods], 21 | formats: [png], 22 | }); 23 | 24 | const image = await MyJimp.read("test/image.png"); 25 | 26 | image.resize({ width: 100 }); 27 | 28 | await image.write("test/output.png"); 29 | ``` 30 | -------------------------------------------------------------------------------- /packages/docs/src/content/docs/guides/getting-started.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Getting Started 3 | description: How to use Jimp 4 | --- 5 | 6 | import { Steps } from "@astrojs/starlight/components"; 7 | import { Aside } from "@astrojs/starlight/components"; 8 | 9 | Jimp (JavaScript Image Manipulation Program) is a package that makes it easy to load and manipulate images in the browser and Node.js. 10 | It aims to run anywhere that JavaScript is supported. 11 | 12 | [Read the full documentation](/api/jimp/classes/jimp/) to learn more about the API. 13 | 14 | ```bash 15 | pnpm add jimp 16 | ``` 17 | 18 | Jimp supports the following image formats: 19 | 20 | - [bmp](https://en.wikipedia.org/wiki/BMP_file_format) 21 | - [gif](https://en.wikipedia.org/wiki/GIF) 22 | - [jpeg](https://en.wikipedia.org/wiki/JPEG) 23 | - [png](https://en.wikipedia.org/wiki/Portable_Network_Graphics) 24 | - [tiff](https://en.wikipedia.org/wiki/TIFF) 25 | 26 | 31 | 32 | ## Usage 33 | 34 | The workflow for using jimp 35 | 36 | 37 | 38 | 1. Load an image. 39 | 40 | ```ts 41 | import { Jimp } from "jimp"; 42 | 43 | const image = await Jimp.read("test/image.png"); 44 | ``` 45 | 46 | 2. Manipulate the image. 47 | 48 | ```ts 49 | image.resize({ width: 100 }); 50 | ``` 51 | 52 | 3. Save the image. 53 | 54 | ```ts 55 | await image.write("test/output.png"); 56 | ``` 57 | 58 | 59 | -------------------------------------------------------------------------------- /packages/docs/src/content/docs/reference/example.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Example Reference 3 | description: A reference page in my new Starlight docs site. 4 | --- 5 | 6 | Reference pages are ideal for outlining how things work in terse and clear terms. 7 | Less concerned with telling a story or addressing a specific use case, they should give a comprehensive outline of what you're documenting. 8 | 9 | ## Further reading 10 | 11 | - Read [about reference](https://diataxis.fr/reference/) in the Diátaxis framework 12 | -------------------------------------------------------------------------------- /packages/docs/src/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /packages/docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "astro/tsconfigs/strict" 3 | } 4 | -------------------------------------------------------------------------------- /packages/file-ops/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | 19 | #### Authors: 1 20 | 21 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 22 | 23 | --- 24 | 25 | # v1.0.3 (Sat Aug 31 2024) 26 | 27 | #### 🐛 Bug Fix 28 | 29 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 30 | 31 | #### ⚠️ Pushed to `main` 32 | 33 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 34 | 35 | #### Authors: 1 36 | 37 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 38 | 39 | --- 40 | 41 | # v1.0.2 (Sat Aug 31 2024) 42 | 43 | #### ⚠️ Pushed to `main` 44 | 45 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 46 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | 49 | #### Authors: 1 50 | 51 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 52 | -------------------------------------------------------------------------------- /packages/file-ops/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /packages/file-ops/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/file-ops", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "build": "tshy", 11 | "dev": "tshy --watch", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "author": "Andrew Lisowski ", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@jimp/config-eslint": "workspace:*", 18 | "@jimp/config-typescript": "workspace:*", 19 | "@types/node": "^18.19.48", 20 | "eslint": "^9.9.1", 21 | "tshy": "^3.0.2", 22 | "typescript": "^5.5.4", 23 | "vitest": "^2.0.5" 24 | }, 25 | "tshy": { 26 | "exclude": [ 27 | "**/*.test.ts" 28 | ], 29 | "esmDialects": [ 30 | "browser" 31 | ], 32 | "exports": { 33 | "./package.json": "./package.json", 34 | ".": "./src/index.ts" 35 | } 36 | }, 37 | "exports": { 38 | "./package.json": "./package.json", 39 | ".": { 40 | "browser": { 41 | "types": "./dist/browser/index.d.ts", 42 | "default": "./dist/browser/index.js" 43 | }, 44 | "import": { 45 | "types": "./dist/esm/index.d.ts", 46 | "default": "./dist/esm/index.js" 47 | }, 48 | "require": { 49 | "types": "./dist/commonjs/index.d.ts", 50 | "default": "./dist/commonjs/index.js" 51 | } 52 | } 53 | }, 54 | "main": "./dist/commonjs/index.js", 55 | "types": "./dist/commonjs/index.d.ts", 56 | "type": "module", 57 | "publishConfig": { 58 | "access": "public" 59 | }, 60 | "sideEffects": false, 61 | "module": "./dist/esm/index.js" 62 | } 63 | -------------------------------------------------------------------------------- /packages/file-ops/src/index-browser.mts: -------------------------------------------------------------------------------- 1 | export const existsSync = () => false; 2 | 3 | export const readFile = async () => { 4 | throw new Error("Not supported"); 5 | }; 6 | 7 | export const writeFile = async () => { 8 | throw new Error("Not supported"); 9 | }; 10 | -------------------------------------------------------------------------------- /packages/file-ops/src/index.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "fs"; 2 | 3 | export { existsSync } from "fs"; 4 | export const readFile = fs.readFile; 5 | export const writeFile = fs.writeFile; 6 | -------------------------------------------------------------------------------- /packages/file-ops/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/jimp/.gitignore: -------------------------------------------------------------------------------- 1 | browser.js 2 | browser.js.map -------------------------------------------------------------------------------- /packages/jimp/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

Jimp

5 |

JavaScript Image Manipulation Program

6 |
7 | 8 | The "JavaScript Image Manipulation Program" :-) 9 | 10 | An image processing library for Node written entirely in JavaScript, with zero native dependencies. 11 | 12 | The default jimp configuration. 13 | 14 | Supported types: 15 | 16 | - `@jimp/jpeg` 17 | - `@jimp/png` 18 | - `@jimp/bmp` 19 | - `@jimp/tiff` 20 | - `@jimp/gif` 21 | 22 | [Read the full docs.](http://jimp-dev.github.io/jimp/) 23 | 24 | ## Installation 25 | 26 | ```bash 27 | npm install --save jimp 28 | ``` 29 | 30 | ## Usage 31 | 32 | ```js 33 | const { Jimp } = require("jimp"); 34 | 35 | // open a file called "lenna.png" 36 | const image = await Jimp.read("test.png"); 37 | 38 | image.resize(256, 256); // resize 39 | 40 | await image.write("test-small.jpg"); // save 41 | ``` 42 | -------------------------------------------------------------------------------- /packages/jimp/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /packages/jimp/scripts/generate-dts-bundle.js: -------------------------------------------------------------------------------- 1 | import { createBundle } from "dts-buddy"; 2 | 3 | await createBundle({ 4 | project: "tsconfig.json", 5 | output: "browser.d.ts", 6 | modules: { 7 | jimp: "dist/esm/index.ts", 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/composite-node-test-ts-composite-can-apply-more-than-one-color-transformation-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/composite-node-test-ts-composite-can-apply-more-than-one-color-transformation-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/composite-node-test-ts-composite-should-handle-edges-correctly-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/composite-node-test-ts-composite-should-handle-edges-correctly-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-1-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-1-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-1-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-1-2-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-2-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-2-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-2-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-2-2-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-3-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-3-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-3-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-3-2-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-4-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-4-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-4-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-4-2-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-5-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-5-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-5-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-5-2-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-6-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-6-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-6-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-6-2-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-7-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-7-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-7-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-7-2-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-8-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-8-1-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-8-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/__image_snapshots__/exif-node-test-ts-exif-orientation-is-fixed-when-exif-orientation-is-8-2-snap.png -------------------------------------------------------------------------------- /packages/jimp/src/__snapshots__/scan.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`scan > create a image with plain color 1`] = ` 4 | Visualization: 5 | 6 | ▴▴▴▴▴▴▴▴ 7 | ▴▴▴▴▴▴▴▴ 8 | ▴▴▴▴▴▴▴▴ 9 | 10 | Data: 11 | 12 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ 13 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ 14 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ 15 | `; 16 | 17 | exports[`scan > draw bars with (get|set)PixelColor 1`] = ` 18 | Visualization: 19 | 20 | ▾▾▴▴▸▸▰▰ 21 | ▾▾▴▴▸▸▰▰ 22 | ▿▿▵▵▹▹▱▱ 23 | 24 | Data: 25 | 26 | 00-00-FFᶠᶠ 00-00-FFᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ 00-FF-00ᶠᶠ 00-FF-00ᶠᶠ FF-00-FFᶠᶠ FF-00-FFᶠᶠ 27 | 00-00-FFᶠᶠ 00-00-FFᶠᶠ FF-00-00ᶠᶠ FF-00-00ᶠᶠ 00-FF-00ᶠᶠ 00-FF-00ᶠᶠ FF-00-FFᶠᶠ FF-00-FFᶠᶠ 28 | 00-00-FF⁷ᶠ 00-00-FF⁷ᶠ FF-00-00⁷ᶠ FF-00-00⁷ᶠ 00-FF-00⁷ᶠ 00-FF-00⁷ᶠ FF-00-FF⁷ᶠ FF-00-FF⁷ᶠ 29 | `; 30 | 31 | exports[`scan > draw bars with iterate scan 1`] = ` 32 | Visualization: 33 | 34 | ▴▴▸▸▾▾◆◆ 35 | ▴▴▸▸▾▾◆◆ 36 | ▵▵▹▹▿▿◇◇ 37 | 38 | Data: 39 | 40 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ 00-FF-00ᶠᶠ 00-FF-00ᶠᶠ 00-00-FFᶠᶠ 00-00-FFᶠᶠ FF-FF-00ᶠᶠ FF-FF-00ᶠᶠ 41 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ 00-FF-00ᶠᶠ 00-FF-00ᶠᶠ 00-00-FFᶠᶠ 00-00-FFᶠᶠ FF-FF-00ᶠᶠ FF-FF-00ᶠᶠ 42 | FF-00-00⁷ᶠ FF-00-00⁷ᶠ 00-FF-00⁷ᶠ 00-FF-00⁷ᶠ 00-00-FF⁷ᶠ 00-00-FF⁷ᶠ FF-FF-00⁷ᶠ FF-FF-00⁷ᶠ 43 | `; 44 | 45 | exports[`scan > draw bars with scan 1`] = ` 46 | Visualization: 47 | 48 | ▴▴▸▸▾▾◆◆ 49 | ▴▴▸▸▾▾◆◆ 50 | ▵▵▹▹▿▿◇◇ 51 | 52 | Data: 53 | 54 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ 00-FF-00ᶠᶠ 00-FF-00ᶠᶠ 00-00-FFᶠᶠ 00-00-FFᶠᶠ FF-FF-00ᶠᶠ FF-FF-00ᶠᶠ 55 | FF-00-00ᶠᶠ FF-00-00ᶠᶠ 00-FF-00ᶠᶠ 00-FF-00ᶠᶠ 00-00-FFᶠᶠ 00-00-FFᶠᶠ FF-FF-00ᶠᶠ FF-FF-00ᶠᶠ 56 | FF-00-00⁷ᶠ FF-00-00⁷ᶠ 00-FF-00⁷ᶠ 00-FF-00⁷ᶠ 00-00-FF⁷ᶠ 00-00-FF⁷ᶠ FF-FF-00⁷ᶠ FF-FF-00⁷ᶠ 57 | `; 58 | -------------------------------------------------------------------------------- /packages/jimp/src/canvas.browser.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import { Jimp } from "./index.js"; 3 | 4 | describe("Canvas", () => { 5 | test("should be able to create a Jimp from a canvas", async () => { 6 | const canvas = document.createElement("canvas"); 7 | const ctx = canvas.getContext("2d")!; 8 | 9 | // make all the pixels red 10 | ctx.fillStyle = "red"; 11 | ctx.fillRect(0, 0, canvas.width, canvas.height); 12 | 13 | const beforeValue = ctx.getImageData(0, 0, canvas.width, canvas.height) 14 | .data[0]; 15 | 16 | const image = await Jimp.fromBitmap( 17 | ctx.getImageData(0, 0, canvas.width, canvas.height) 18 | ); 19 | 20 | // The jimp image is red 21 | expect(image.bitmap.data[0]).toBe(255); 22 | expect(image.bitmap.data[1]).toBe(0); 23 | expect(image.bitmap.data[2]).toBe(0); 24 | expect(image.bitmap.data[3]).toBe(255); 25 | 26 | // Modify the image 27 | image.greyscale(); 28 | 29 | const imageData = new ImageData( 30 | new Uint8ClampedArray(image.bitmap.data), 31 | image.bitmap.width, 32 | image.bitmap.height 33 | ); 34 | 35 | // Write back to the canvas 36 | ctx.putImageData(imageData, 0, 0); 37 | 38 | // The canvas should have changed 39 | expect(beforeValue).not.toBe( 40 | ctx.getImageData(0, 0, canvas.width, canvas.height).data[0] 41 | ); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /packages/jimp/src/composite.node.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | 3 | import "@jimp/test-utils/image-snapshot"; 4 | import { getTestImagePath } from "@jimp/test-utils"; 5 | 6 | import { Jimp, BlendMode } from "./index.js"; 7 | 8 | describe("composite", () => { 9 | test("can apply more than one color transformation", async () => { 10 | const mask = new Jimp({ height: 100, width: 100, color: 0x0000ff }); 11 | const cops = await Jimp.read(getTestImagePath("cops.jpg")); 12 | 13 | cops.composite(mask, 0, 0, { 14 | mode: BlendMode.SRC_OVER, 15 | opacitySource: 0.5, 16 | opacityDest: 0.5, 17 | }); 18 | 19 | const output = await cops.getBuffer("image/png"); 20 | expect(output).toMatchImageSnapshot(); 21 | }); 22 | 23 | test("should handle edges correctly", async () => { 24 | const background = new Jimp({ height: 100, width: 100, color: 0x0000ff }); 25 | const cops = await Jimp.read(getTestImagePath("cops.jpg")); 26 | 27 | background.composite(cops, 0, -(cops.bitmap.height / 2), { 28 | mode: BlendMode.SRC_OVER, 29 | opacityDest: 1, 30 | opacitySource: 0.8, 31 | }); 32 | 33 | const output = await background.getBuffer("image/png"); 34 | expect(output).toMatchImageSnapshot(); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /packages/jimp/src/fonts.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module jimp/fonts 3 | */ 4 | 5 | export * from "@jimp/plugin-print/fonts"; 6 | -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Landscape_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Landscape_1.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Landscape_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Landscape_2.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Landscape_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Landscape_3.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Landscape_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Landscape_4.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Landscape_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Landscape_5.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Landscape_6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Landscape_6.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Landscape_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Landscape_7.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Landscape_8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Landscape_8.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Portrait_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Portrait_1.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Portrait_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Portrait_2.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Portrait_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Portrait_3.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Portrait_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Portrait_4.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Portrait_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Portrait_5.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Portrait_6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Portrait_6.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Portrait_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Portrait_7.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/Portrait_8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/jimp/src/images/exif-orientation/Portrait_8.jpg -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/README.markdown: -------------------------------------------------------------------------------- 1 | # EXIF Orientation-flag example images 2 | 3 | Example images using each of the EXIF orientation flags (1-to-8), in both landscape and portrait orientations. 4 | 5 | [See here](http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/) for more information. 6 | 7 | ## Change history 8 | 9 | - **Version 1.0.1 (2013-03-10)** : Add MIT license and some contact details. 10 | - **Version 1.0.0 (2012-07-28)** : 1.0 release. 11 | 12 | ## Contributing 13 | 14 | Once you've made your commits: 15 | 16 | 1. [Fork](http://help.github.com/fork-a-repo/) exif-orientation-examples 17 | 2. Create a topic branch - `git checkout -b my_branch` 18 | 3. Push to your branch - `git push origin my_branch` 19 | 4. Create a [Pull Request](http://help.github.com/pull-requests/) from your branch 20 | 5. That's it! 21 | 22 | ## Author 23 | 24 | Dave Perrett :: hello@daveperrett.com :: [@daveperrett](http://twitter.com/daveperrett) 25 | 26 | ## Copyright 27 | 28 | These images are licensed under the [MIT License](http://opensource.org/licenses/MIT). 29 | 30 | Copyright (c) 2010 Dave Perrett. See [License](https://github.com/recurser/exif-orientation-examples/blob/master/LICENSE) for details. 31 | -------------------------------------------------------------------------------- /packages/jimp/src/images/exif-orientation/VERSION: -------------------------------------------------------------------------------- 1 | 1.0.1 -------------------------------------------------------------------------------- /packages/jimp/src/index-browser.mts: -------------------------------------------------------------------------------- 1 | // A stub. The real build is done by rollup. 2 | -------------------------------------------------------------------------------- /packages/jimp/src/jimp.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test } from "vitest"; 2 | import { Jimp } from "./index.js"; 3 | import { getTestImagePath } from "@jimp/test-utils"; 4 | 5 | describe("hasAlpha", () => { 6 | test("image with no alpha", async () => { 7 | const image = await Jimp.read(getTestImagePath("cops.jpg")); 8 | expect(image.hasAlpha()).toBe(false); 9 | }); 10 | 11 | test("image with alpha", async () => { 12 | const image = await Jimp.read(getTestImagePath("dice.png")); 13 | expect(image.hasAlpha()).toBe(true); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /packages/jimp/tsconfig.docs.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["**/*.test.*"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/jimp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/jimp/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/test-utils/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | 19 | #### Authors: 1 20 | 21 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 22 | 23 | --- 24 | 25 | # v1.0.3 (Sat Aug 31 2024) 26 | 27 | #### 🐛 Bug Fix 28 | 29 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 30 | 31 | #### ⚠️ Pushed to `main` 32 | 33 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 34 | - fix build ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /packages/test-utils/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /packages/test-utils/images/animated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/animated.gif -------------------------------------------------------------------------------- /packages/test-utils/images/cops.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/cops.jpg -------------------------------------------------------------------------------- /packages/test-utils/images/dice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/dice.png -------------------------------------------------------------------------------- /packages/test-utils/images/fillbytes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/fillbytes.jpg -------------------------------------------------------------------------------- /packages/test-utils/images/flower.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/flower.gif -------------------------------------------------------------------------------- /packages/test-utils/images/hands.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/hands.jpg -------------------------------------------------------------------------------- /packages/test-utils/images/hands_mx200_rp255.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/hands_mx200_rp255.jpg -------------------------------------------------------------------------------- /packages/test-utils/images/mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/mask.png -------------------------------------------------------------------------------- /packages/test-utils/images/panoramic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/panoramic.jpg -------------------------------------------------------------------------------- /packages/test-utils/images/rgb.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/rgb.tiff -------------------------------------------------------------------------------- /packages/test-utils/images/windows95.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/windows95.bmp -------------------------------------------------------------------------------- /packages/test-utils/images/windows95.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/packages/test-utils/images/windows95.png -------------------------------------------------------------------------------- /packages/test-utils/src/image-snapshot.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "vitest"; 2 | import { toMatchImageSnapshot } from "jest-image-snapshot"; 3 | 4 | declare module "vitest" { 5 | interface Assertion { 6 | toMatchImageSnapshot: () => T; 7 | } 8 | } 9 | 10 | expect.extend({ toMatchImageSnapshot }); 11 | -------------------------------------------------------------------------------- /packages/test-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/types/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /packages/types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/types", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "build": "tshy", 11 | "dev": "tshy --watch", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "author": "Andrew Lisowski ", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@jimp/config-eslint": "workspace:*", 18 | "@jimp/config-typescript": "workspace:*", 19 | "@types/node": "^18.19.48", 20 | "eslint": "^9.9.1", 21 | "tshy": "^3.0.2", 22 | "typescript": "^5.5.4", 23 | "vite-plugin-node-polyfills": "^0.22.0", 24 | "vitest": "^2.0.5" 25 | }, 26 | "tshy": { 27 | "exclude": [ 28 | "**/*.test.ts" 29 | ], 30 | "exports": { 31 | "./package.json": "./package.json", 32 | ".": "./src/index.ts" 33 | } 34 | }, 35 | "exports": { 36 | "./package.json": "./package.json", 37 | ".": { 38 | "import": { 39 | "types": "./dist/esm/index.d.ts", 40 | "default": "./dist/esm/index.js" 41 | }, 42 | "require": { 43 | "types": "./dist/commonjs/index.d.ts", 44 | "default": "./dist/commonjs/index.js" 45 | } 46 | } 47 | }, 48 | "main": "./dist/commonjs/index.js", 49 | "types": "./dist/commonjs/index.d.ts", 50 | "type": "module", 51 | "dependencies": { 52 | "zod": "^3.23.8" 53 | }, 54 | "publishConfig": { 55 | "access": "public" 56 | }, 57 | "sideEffects": false, 58 | "module": "./dist/esm/index.js" 59 | } 60 | -------------------------------------------------------------------------------- /packages/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/utils/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /packages/utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/utils", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "test": "vitest", 11 | "build": "tshy", 12 | "dev": "tshy --watch", 13 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 14 | }, 15 | "author": "Andrew Lisowski ", 16 | "license": "MIT", 17 | "dependencies": { 18 | "@jimp/types": "workspace:*", 19 | "tinycolor2": "^1.6.0" 20 | }, 21 | "devDependencies": { 22 | "@jimp/config-eslint": "workspace:*", 23 | "@jimp/config-typescript": "workspace:*", 24 | "@types/node": "^18.19.48", 25 | "@types/tinycolor2": "^1.4.6", 26 | "eslint": "^9.9.1", 27 | "tshy": "^3.0.2", 28 | "typescript": "^5.5.4", 29 | "vite-plugin-node-polyfills": "^0.22.0", 30 | "vitest": "^2.0.5" 31 | }, 32 | "tshy": { 33 | "exclude": [ 34 | "**/*.test.ts" 35 | ], 36 | "exports": { 37 | "./package.json": "./package.json", 38 | ".": "./src/index.ts" 39 | } 40 | }, 41 | "exports": { 42 | "./package.json": "./package.json", 43 | ".": { 44 | "import": { 45 | "types": "./dist/esm/index.d.ts", 46 | "default": "./dist/esm/index.js" 47 | }, 48 | "require": { 49 | "types": "./dist/commonjs/index.d.ts", 50 | "default": "./dist/commonjs/index.js" 51 | } 52 | } 53 | }, 54 | "main": "./dist/commonjs/index.js", 55 | "types": "./dist/commonjs/index.d.ts", 56 | "type": "module", 57 | "publishConfig": { 58 | "access": "public" 59 | }, 60 | "sideEffects": false, 61 | "module": "./dist/esm/index.js" 62 | } 63 | -------------------------------------------------------------------------------- /packages/utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/js-bmp/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/bmp

5 |

Default Jimp bmp encoder/decoder.

6 |
7 | -------------------------------------------------------------------------------- /plugins/js-bmp/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/js-bmp/src/images/windows95.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/js-bmp/src/images/windows95.bmp -------------------------------------------------------------------------------- /plugins/js-bmp/src/images/windows95.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/js-bmp/src/images/windows95.png -------------------------------------------------------------------------------- /plugins/js-bmp/src/index.node.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | import { getTestImagePath } from "@jimp/test-utils"; 4 | 5 | import png from "@jimp/js-png"; 6 | import bmp from "./index.js"; 7 | 8 | const jimp = createJimp({ formats: [bmp, png] }); 9 | 10 | describe("BMP", () => { 11 | test("uses correct colors for BMP", async function () { 12 | const expectedImg = await jimp.read(getTestImagePath("windows95.png")); 13 | const image = await jimp.read(getTestImagePath("windows95.bmp")); 14 | 15 | expect(image.bitmap.data).toEqual(expectedImg.bitmap.data); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /plugins/js-bmp/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | import { getTestImagePath } from "@jimp/test-utils"; 4 | 5 | import png from "@jimp/js-png"; 6 | import bmp from "./index.js"; 7 | 8 | const jimp = createJimp({ formats: [bmp, png] }); 9 | 10 | describe("BMP", () => { 11 | test("load BMP", async () => { 12 | const image = await jimp.read(getTestImagePath("windows95.bmp")); 13 | 14 | expect(image.getPixelColor(10, 10)).toBe(0xeff7f7ff); 15 | expect(image.getPixelColor(150, 80)).toBe(0x73add6ff); 16 | expect(image.getPixelColor(190, 200)).toBe(0xf7c300ff); 17 | }); 18 | 19 | test("export BMP", async () => { 20 | const image = jimp.fromBitmap({ 21 | width: 3, 22 | height: 3, 23 | data: [ 24 | 0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff, 25 | 0xff00ffff, 0x8000ffff, 0x0000ffff, 26 | ], 27 | }); 28 | const buffer = await image.getBuffer("image/bmp"); 29 | 30 | expect(buffer.toString()).toMatch(/^BM/); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /plugins/js-bmp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/js-bmp/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/js-gif/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.0.3 (Sat Aug 31 2024) 14 | 15 | #### 🐛 Bug Fix 16 | 17 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | 19 | #### ⚠️ Pushed to `main` 20 | 21 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 22 | 23 | #### Authors: 1 24 | 25 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 26 | 27 | --- 28 | 29 | # v1.0.2 (Sat Aug 31 2024) 30 | 31 | #### ⚠️ Pushed to `main` 32 | 33 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 34 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 36 | 37 | #### Authors: 1 38 | 39 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 40 | -------------------------------------------------------------------------------- /plugins/js-gif/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/gif

5 |

Default Jimp gif decoder.

6 |
7 | 8 | NOTE: Only supports single frame 9 | -------------------------------------------------------------------------------- /plugins/js-gif/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/js-gif/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | import { getTestImagePath } from "@jimp/test-utils"; 4 | 5 | import gif from "./index.js"; 6 | 7 | const jimp = createJimp({ formats: [gif] }); 8 | 9 | describe("GIF", () => { 10 | test("load GIF", async () => { 11 | const image = await jimp.read(getTestImagePath("flower.gif")); 12 | expect(image.getPixelColor(10, 10)).toBe(0xfefefeff); 13 | }); 14 | 15 | test("load animated GIF", async () => { 16 | const image = await jimp.read(getTestImagePath("animated.gif")); 17 | expect(image.getPixelColor(10, 10)).toBe(0xa1d2f1ff); 18 | }); 19 | 20 | test("export GIF", async () => { 21 | const jgd = await jimp.read(getTestImagePath("flower.gif")); 22 | const buffer = await jgd.getBuffer("image/gif"); 23 | expect(buffer.toString()).toMatch(/^GIF/); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /plugins/js-gif/src/index.ts: -------------------------------------------------------------------------------- 1 | import GIF from "omggif"; 2 | import { GifUtil, GifFrame, BitmapImage, GifCodec } from "gifwrap"; 3 | import { Format } from "@jimp/types"; 4 | 5 | export interface JPEGOptions { 6 | quality?: number; 7 | } 8 | 9 | export default function gif() { 10 | return { 11 | mime: "image/gif", 12 | encode: async (bitmap) => { 13 | const gif = new BitmapImage(bitmap); 14 | GifUtil.quantizeDekker(gif, 256); 15 | const newFrame = new GifFrame(bitmap); 16 | const gifCodec = new GifCodec(); 17 | const newGif = await gifCodec.encodeGif([newFrame], {}); 18 | return newGif.buffer; 19 | }, 20 | decode: (data) => { 21 | const gifObj = new GIF.GifReader(data); 22 | const gifData = Buffer.alloc(gifObj.width * gifObj.height * 4); 23 | 24 | gifObj.decodeAndBlitFrameRGBA(0, gifData); 25 | 26 | return { 27 | data: gifData, 28 | width: gifObj.width, 29 | height: gifObj.height, 30 | }; 31 | }, 32 | } satisfies Format<"image/gif">; 33 | } 34 | -------------------------------------------------------------------------------- /plugins/js-gif/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/js-gif/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/js-jpeg/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/jpeg

5 |

Default Jimp jpeg encoder/decoder.

6 |
7 | -------------------------------------------------------------------------------- /plugins/js-jpeg/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/js-jpeg/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | import { getTestImagePath } from "@jimp/test-utils"; 4 | 5 | import jpeg from "./index.js"; 6 | 7 | const jimp = createJimp({ formats: [jpeg] }); 8 | 9 | describe("JPEG", () => { 10 | test("load JPG", async () => { 11 | const image = await jimp.read(getTestImagePath("cops.jpg")); 12 | 13 | expect(image.getPixelColor(10, 10)).toBe(0x3f4a02ff); 14 | expect(image.getPixelColor(220, 190)).toBe(0x5d94b6ff); 15 | expect(image.getPixelColor(350, 130)).toBe(0xdf7944ff); 16 | }); 17 | 18 | test("load JPG with fill bytes", async () => { 19 | const image = await jimp.read(getTestImagePath("fillbytes.jpg")); 20 | 21 | expect(image.getPixelColor(10, 10)).toBe(0xaeb8c3ff); 22 | expect(image.getPixelColor(220, 190)).toBe(0x262b21ff); 23 | expect(image.getPixelColor(350, 130)).toBe(0x4e5d30ff); 24 | }); 25 | 26 | test("export JPG", async () => { 27 | const image = jimp.fromBitmap({ 28 | width: 3, 29 | height: 3, 30 | data: [ 31 | 0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff, 32 | 0xff00ffff, 0x8000ffff, 0x0000ffff, 33 | ], 34 | }); 35 | 36 | const buffer = await image.getBuffer("image/jpeg", { 37 | quality: 50, 38 | }); 39 | 40 | // eslint-disable-next-line no-control-regex 41 | expect(buffer.toString()).toMatch(/^.{3,9}JFIF\u0000/); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /plugins/js-jpeg/src/index.ts: -------------------------------------------------------------------------------- 1 | import JPEG from "jpeg-js"; 2 | import { Format } from "@jimp/types"; 3 | 4 | export interface JPEGOptions { 5 | quality?: number; 6 | } 7 | 8 | export interface DecodeJpegOptions { 9 | useTArray?: false; 10 | colorTransform?: boolean; 11 | formatAsRGBA?: boolean; 12 | tolerantDecoding?: boolean; 13 | maxResolutionInMP?: number; 14 | maxMemoryUsageInMB?: number; 15 | } 16 | 17 | export default function jpeg() { 18 | return { 19 | mime: "image/jpeg", 20 | encode: (bitmap, { quality = 100 }: JPEGOptions = {}) => 21 | JPEG.encode(bitmap, quality).data, 22 | decode: (data, options?: DecodeJpegOptions) => JPEG.decode(data, options), 23 | } satisfies Format<"image/jpeg">; 24 | } 25 | -------------------------------------------------------------------------------- /plugins/js-jpeg/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/js-jpeg/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/js-png/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/png

5 |

Default Jimp png encoder/decoder.

6 |
7 | 8 | ## Available Methods 9 | 10 | ### Jimp.deflateLevel 11 | 12 | Sets the deflate level used when saving as PNG format (default is 9) 13 | 14 | ### Jimp.deflateStrategy 15 | 16 | Sets the deflate strategy used when saving as PNG format (default is 3) 17 | 18 | ### Jimp.filterType 19 | 20 | Sets the filter type used when saving as PNG format (default is automatic filters) 21 | 22 | ### Jimp.colorType 23 | 24 | Sets the color type used when saving as PNG format (one of 0, 2, 4, 6) 25 | 26 | ### Filter Types 27 | 28 | ```js 29 | Jimp.PNG_FILTER_AUTO; 30 | Jimp.PNG_FILTER_NONE; 31 | Jimp.PNG_FILTER_SUB; 32 | Jimp.PNG_FILTER_UP; 33 | Jimp.PNG_FILTER_AVERAGE; 34 | Jimp.PNG_FILTER_PATH; 35 | ``` 36 | -------------------------------------------------------------------------------- /plugins/js-png/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/js-png/src/__image_snapshots__/index-node-test-ts-png-should-use-png-options-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/js-png/src/__image_snapshots__/index-node-test-ts-png-should-use-png-options-1-snap.png -------------------------------------------------------------------------------- /plugins/js-png/src/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Filter method is a single-byte integer that indicates the preprocessing method applied to the image data before compression. 3 | */ 4 | export enum PNGFilterType { 5 | AUTO = -1, 6 | /** scanline is transmitted unmodified */ 7 | NONE = 0, 8 | /** filter transmits the difference between each byte and the value of the corresponding byte of the prior pixel */ 9 | SUB = 1, 10 | /** 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. */ 11 | UP = 2, 12 | /** uses the average of the two neighboring pixels (left and above) to predict the value of a pixel */ 13 | AVERAGE = 3, 14 | /** 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. */ 15 | PATH = 4, 16 | } 17 | 18 | /** 19 | * Color type is a single-byte integer that describes the interpretation of the image data. 20 | * Color type codes represent sums of the following values: 21 | * 22 | * 1 (palette used), 2 (color used), and 4 (alpha channel used). 23 | */ 24 | export enum PNGColorType { 25 | GRAYSCALE = 0, 26 | COLOR = 2, 27 | GRAYSCALE_ALPHA = 4, 28 | COLOR_ALPHA = 6, 29 | } 30 | -------------------------------------------------------------------------------- /plugins/js-png/src/index.node.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import "@jimp/test-utils/image-snapshot"; 3 | import { createJimp } from "@jimp/core"; 4 | 5 | import png from "./index.js"; 6 | 7 | const jimp = createJimp({ formats: [png] }); 8 | 9 | describe("PNG", () => { 10 | test("should use png options", async () => { 11 | const testImage = jimp.fromBitmap({ 12 | width: 20, 13 | height: 20, 14 | data: [ 15 | 0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff, 16 | 0xff00ffff, 0x8000ffff, 0x0000ffff, 0xff0000ff, 0xff0080ff, 0xff00ffff, 17 | 0xff0080ff, 0xff00ffff, 0x8000ffff, 0xff00ffff, 0x8000ffff, 0x0000ffff, 18 | 0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff, 19 | 0xff00ffff, 0x8000ffff, 0x0000ffff, 0xff0000ff, 0xff0080ff, 0xff00ffff, 20 | 0xff0080ff, 0xff00ffff, 0x8000ffff, 0xff00ffff, 0x8000ffff, 0x0000ffff, 21 | ], 22 | }); 23 | const image = await testImage.getBuffer("image/png", { 24 | deflateStrategy: 0, 25 | colorType: 0, 26 | }); 27 | expect(image).toMatchImageSnapshot(); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /plugins/js-png/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | 4 | import png from "./index.js"; 5 | import { getTestImagePath } from "@jimp/test-utils"; 6 | 7 | const jimp = createJimp({ formats: [png] }); 8 | 9 | describe("PNG", () => { 10 | test("load PNG", async () => { 11 | const image = await jimp.read(getTestImagePath("dice.png")); 12 | expect(image.getPixelColor(10, 10)).toBe(0x00000000); 13 | expect(image.getPixelColor(160, 80)).toBe(0x1c1cd4ff); 14 | expect(image.getPixelColor(400, 250)).toBe(0x7e0c0cda); 15 | }); 16 | 17 | test("export PNG", async () => { 18 | const testImage = jimp.fromBitmap({ 19 | width: 3, 20 | height: 3, 21 | data: [ 22 | 0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff, 23 | 0xff00ffff, 0x8000ffff, 0x0000ffff, 24 | ], 25 | }); 26 | const buffer = await testImage.getBuffer("image/png"); 27 | expect(buffer.toString()).toMatch(/^.PNG\r\n/); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /plugins/js-png/src/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/js-png/src/output.png -------------------------------------------------------------------------------- /plugins/js-png/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/js-png/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/js-tiff/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | 19 | #### Authors: 1 20 | 21 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 22 | 23 | --- 24 | 25 | # v1.0.3 (Sat Aug 31 2024) 26 | 27 | #### 🐛 Bug Fix 28 | 29 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 30 | 31 | #### ⚠️ Pushed to `main` 32 | 33 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 34 | 35 | #### Authors: 1 36 | 37 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 38 | 39 | --- 40 | 41 | # v1.0.2 (Sat Aug 31 2024) 42 | 43 | #### ⚠️ Pushed to `main` 44 | 45 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 46 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | 49 | #### Authors: 1 50 | 51 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 52 | -------------------------------------------------------------------------------- /plugins/js-tiff/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/tiff

5 |

Default Jimp tiff encoder/decoder.

6 |
7 | -------------------------------------------------------------------------------- /plugins/js-tiff/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/js-tiff/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | import { getTestImagePath } from "@jimp/test-utils"; 4 | 5 | import tiff from "./index.js"; 6 | 7 | const jimp = createJimp({ formats: [tiff] }); 8 | 9 | describe("TIFF", () => { 10 | test("load TIFF", async () => { 11 | const image = await jimp.read(getTestImagePath("rgb.tiff")); 12 | 13 | expect(image.getPixelColor(10, 10)).toBe(0xa4988bff); 14 | expect(image.getPixelColor(220, 190)).toBe(0xe0d7ddff); 15 | expect(image.getPixelColor(350, 130)).toBe(0x565433ff); 16 | }); 17 | 18 | test("export TIFF", async () => { 19 | const image = jimp.fromBitmap({ 20 | width: 3, 21 | height: 3, 22 | data: [ 23 | 0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff, 24 | 0xff00ffff, 0x8000ffff, 0x0000ffff, 25 | ], 26 | }); 27 | const buffer = await image.getBuffer("image/tiff"); 28 | 29 | // eslint-disable-next-line no-control-regex 30 | expect(buffer.toString()).toMatch(/^MM\u0000*\u0000/); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /plugins/js-tiff/src/index.ts: -------------------------------------------------------------------------------- 1 | import utif, { TiffTag } from "utif2"; 2 | import { Bitmap, Format } from "@jimp/types"; 3 | 4 | function getDimensionValue(dimension: number | Uint8Array | TiffTag) { 5 | if (typeof dimension === "number") { 6 | return dimension; 7 | } 8 | 9 | if (dimension instanceof Uint8Array) { 10 | return dimension[0]; 11 | } 12 | 13 | if (typeof dimension[0] === "string") { 14 | return parseInt(dimension[0]); 15 | } 16 | 17 | return dimension[0]; 18 | } 19 | 20 | export default function tiff() { 21 | return { 22 | mime: "image/tiff", 23 | encode: (bitmap) => { 24 | const tiff = utif.encodeImage(bitmap.data, bitmap.width, bitmap.height); 25 | return Buffer.from(tiff); 26 | }, 27 | decode: (data) => { 28 | const ifds = utif.decode(data); 29 | const page = ifds[0]; 30 | 31 | if (!page) { 32 | throw new Error("No page found in TIFF"); 33 | } 34 | 35 | if (!page.t256) { 36 | throw new Error("No image width found in TIFF"); 37 | } 38 | 39 | if (!page.t257) { 40 | throw new Error("No image height found in TIFF"); 41 | } 42 | 43 | ifds.forEach((ifd) => { 44 | utif.decodeImage(data, ifd); 45 | }); 46 | 47 | const rgba = utif.toRGBA8(page); 48 | 49 | return { 50 | data: Buffer.from(rgba), 51 | width: getDimensionValue(page.t256), 52 | height: getDimensionValue(page.t257), 53 | } as Bitmap; 54 | }, 55 | } satisfies Format<"image/tiff">; 56 | } 57 | -------------------------------------------------------------------------------- /plugins/js-tiff/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/js-tiff/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-blit/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-blit

5 |

Blit an image.

6 |
7 | 8 | > Blit - a data operation commonly used in computer graphics in which several bitmaps are combined into one using a boolean function. 9 | 10 | [Read the docs](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#blit) 11 | -------------------------------------------------------------------------------- /plugins/plugin-blit/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-blit-alpha-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-blit-alpha-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-uses-src-params-correctly-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-uses-src-params-correctly-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-uses-src-params-correctly-2-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-uses-src-params-correctly-2-snap.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-uses-src-params-correctly-3-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-uses-src-params-correctly-3-snap.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/images/blit-alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/images/blit-alpha.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/images/cat-results/large-cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/images/cat-results/large-cat.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/images/cat-results/medium-cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/images/cat-results/medium-cat.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/images/cat-results/small-cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/images/cat-results/small-cat.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/images/cat_butt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/images/cat_butt.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/images/cat_fuzz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/images/cat_fuzz.png -------------------------------------------------------------------------------- /plugins/plugin-blit/src/images/cat_head.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blit/src/images/cat_head.png -------------------------------------------------------------------------------- /plugins/plugin-blit/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-blit/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-blur/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-blur

5 |

Blur an image.

6 |
7 | 8 | A fast blur algorithm that produces similar effect to a Gaussian blur - but MUCH quicker 9 | 10 | - [blur](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#blur) 11 | - [gaussian](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#gaussian) 12 | -------------------------------------------------------------------------------- /plugins/plugin-blur/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-blur/src/__image_snapshots__/index-node-test-ts-has-alpha-image-with-alpha-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-blur/src/__image_snapshots__/index-node-test-ts-has-alpha-image-with-alpha-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-blur/src/index.node.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | import { getTestImagePath } from "@jimp/test-utils"; 4 | import "@jimp/test-utils/image-snapshot"; 5 | import png from "@jimp/js-png"; 6 | 7 | import * as blur from "./index.js"; 8 | 9 | const Jimp = createJimp({ formats: [png], plugins: [blur.methods] }); 10 | 11 | describe("hasAlpha", () => { 12 | test("image with alpha", async () => { 13 | const image = await Jimp.read(getTestImagePath("dice.png")); 14 | const output = await image.blur(16).getBuffer("image/png"); 15 | expect(output).toMatchImageSnapshot(); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /plugins/plugin-blur/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-blur/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-circle/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-circle/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-circle

5 |

Creates a circle out of an image.

6 |
7 | 8 | - [circle](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#circle) 9 | -------------------------------------------------------------------------------- /plugins/plugin-circle/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-circle/src/index.ts: -------------------------------------------------------------------------------- 1 | import { JimpClass } from "@jimp/types"; 2 | import { z } from "zod"; 3 | 4 | const CircleOptionsSchema = z.object({ 5 | /** the x position to draw the circle */ 6 | x: z.number().optional(), 7 | /** the y position to draw the circle */ 8 | y: z.number().optional(), 9 | /** the radius of the circle */ 10 | radius: z.number().min(0).optional(), 11 | }); 12 | 13 | export type CircleOptions = z.infer; 14 | 15 | export const methods = { 16 | /** 17 | * Creates a circle out of an image. 18 | * @example 19 | * ```ts 20 | * import { Jimp } from "jimp"; 21 | * 22 | * const image = await Jimp.read("test/image.png"); 23 | * 24 | * image.circle(); 25 | * // or 26 | * image.circle({ radius: 50, x: 25, y: 25 }); 27 | * ``` 28 | */ 29 | circle(image: I, options: CircleOptions = {}) { 30 | const parsed = CircleOptionsSchema.parse(options); 31 | const radius = 32 | parsed.radius || 33 | (image.bitmap.width > image.bitmap.height 34 | ? image.bitmap.height 35 | : image.bitmap.width) / 2; 36 | 37 | const center = { 38 | x: typeof parsed.x === "number" ? parsed.x : image.bitmap.width / 2, 39 | y: typeof parsed.y === "number" ? parsed.y : image.bitmap.height / 2, 40 | }; 41 | 42 | image.scan((x, y, idx) => { 43 | const curR = Math.sqrt( 44 | Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2), 45 | ); 46 | 47 | if (radius - curR <= 0.0) { 48 | image.bitmap.data[idx + 3] = 0; 49 | } else if (radius - curR < 1.0) { 50 | image.bitmap.data[idx + 3] = 255 * (radius - curR); 51 | } 52 | }); 53 | 54 | return image; 55 | }, 56 | }; 57 | -------------------------------------------------------------------------------- /plugins/plugin-circle/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-circle/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-color/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/utils

5 |

Utils for jimp extensions.

6 |
7 | 8 | - [color](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#color) 9 | - [brightness](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#brightness) 10 | - [contrast](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#contrast) 11 | - [posterize](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#posterize) 12 | - [opacity](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#opacity) 13 | - [sepia](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#sepia) 14 | - [fade](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#fade) 15 | - [convolution](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#convolution) 16 | - [opaque](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#opaque) 17 | - [pixelate](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#pixelate) 18 | - [convolute](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#convolute) 19 | - [normalize](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#normalize) 20 | - [invert](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#invert) 21 | -------------------------------------------------------------------------------- /plugins/plugin-color/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-color/src/__image_snapshots__/birghtness-node-test-ts-brightness-3-x-3-box-blur-matrix-using-convolute-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-color/src/__image_snapshots__/birghtness-node-test-ts-brightness-3-x-3-box-blur-matrix-using-convolute-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-color/src/__image_snapshots__/convolution-node-test-ts-convolution-3-x-3-box-blur-matrix-using-convolute-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-color/src/__image_snapshots__/convolution-node-test-ts-convolution-3-x-3-box-blur-matrix-using-convolute-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-color/src/__image_snapshots__/convolution-node-test-ts-convolution-new-pixel-value-is-greater-than-255-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-color/src/__image_snapshots__/convolution-node-test-ts-convolution-new-pixel-value-is-greater-than-255-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-color/src/__snapshots__/normalize.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`Normalize > change grayscale image 1`] = ` 4 | Visualization: 5 | 6 | ■5▦ 7 | 5▦A 8 | ▦A□ 9 | 10 | Data: 11 | 12 | 00-00-00ᶠᶠ 55-55-55ᶠᶠ 80-80-80ᶠᶠ 13 | 55-55-55ᶠᶠ 80-80-80ᶠᶠ AA-AA-AAᶠᶠ 14 | 80-80-80ᶠᶠ AA-AA-AAᶠᶠ FF-FF-FFᶠᶠ 15 | `; 16 | 17 | exports[`Normalize > change red/blue image 1`] = ` 18 | Visualization: 19 | 20 | ■□▩ 21 | E▸▰ 22 | 23 | Data: 24 | 25 | 00-00-00ᶠᶠ 7F-00-66ᶠᶠ 7F-00-66⁰⁰ 26 | 7F-00-00ᶠᶠ 00-00-66ᶠᶠ FF-00-FFᶠᶠ 27 | `; 28 | -------------------------------------------------------------------------------- /plugins/plugin-color/src/birghtness.node.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import png from "@jimp/js-png"; 3 | import jpeg from "@jimp/js-jpeg"; 4 | import { createJimp } from "@jimp/core"; 5 | import "@jimp/test-utils/image-snapshot"; 6 | 7 | import { methods } from "./index.js"; 8 | 9 | const jimp = createJimp({ formats: [png, jpeg], plugins: [methods] }); 10 | 11 | describe("Brightness", function () { 12 | test("3x3 box blur matrix using convolute", async () => { 13 | const image = await jimp.read(__dirname + "/images/tiles.jpg"); 14 | const output = await image.brightness(2).getBuffer("image/png"); 15 | 16 | expect(output).toMatchImageSnapshot(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /plugins/plugin-color/src/convolution.node.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import png from "@jimp/js-png"; 3 | import jpeg from "@jimp/js-jpeg"; 4 | import { createJimp } from "@jimp/core"; 5 | import "@jimp/test-utils/image-snapshot"; 6 | 7 | import { methods } from "./index.js"; 8 | 9 | const jimp = createJimp({ formats: [png, jpeg], plugins: [methods] }); 10 | 11 | describe("Convolution", function () { 12 | const blurM = [ 13 | [1 / 9, 1 / 9, 1 / 9], 14 | [1 / 9, 1 / 9, 1 / 9], 15 | [1 / 9, 1 / 9, 1 / 9], 16 | ]; 17 | 18 | test("3x3 box blur matrix using convolute", async () => { 19 | const image = await jimp.read(__dirname + "/images/tiles.jpg"); 20 | const output = await image.convolute(blurM).getBuffer("image/png"); 21 | 22 | expect(output).toMatchImageSnapshot(); 23 | }); 24 | 25 | test("new pixel value is greater than 255", async () => { 26 | const image = await jimp.read(__dirname + "/images/qr.jpg"); 27 | 28 | const convolutionMatrix = [ 29 | [0, 0, 0, 0, 0], 30 | [0, 1, 1, 1, 0], 31 | [0, 1, 0, 1, 0], 32 | [0, 1, 1, 1, 0], 33 | [0, 0, 0, 0, 0], 34 | ]; 35 | 36 | const output = await image 37 | .convolution(convolutionMatrix) 38 | .getBuffer("image/png"); 39 | 40 | expect(output).toMatchImageSnapshot(); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /plugins/plugin-color/src/images/qr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-color/src/images/qr.jpg -------------------------------------------------------------------------------- /plugins/plugin-color/src/images/tiles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-color/src/images/tiles.jpg -------------------------------------------------------------------------------- /plugins/plugin-color/src/normalize.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | 3 | import { makeTestImage } from "@jimp/test-utils"; 4 | 5 | import { methods } from "./index.js"; 6 | import { createJimp } from "@jimp/core"; 7 | 8 | const jimp = createJimp({ plugins: [methods] }); 9 | 10 | describe("Normalize", () => { 11 | test("change grayscale image", () => { 12 | const image = jimp.fromBitmap(makeTestImage("36▦", "6▦9", "▦9C")); 13 | expect(image.normalize()).toMatchSnapshot(); 14 | }); 15 | 16 | test("change red/blue image", () => { 17 | const image = jimp.fromBitmap({ 18 | width: 3, 19 | height: 2, 20 | data: [ 21 | 0x000000ff, 0x400022ff, 0x40002200, 0x400000ff, 0x000022ff, 0x800055ff, 22 | ], 23 | }); 24 | 25 | expect(image.normalize()).toMatchSnapshot(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /plugins/plugin-color/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-color/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-contain/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-contain/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-contain

5 |

Contain an image within a height and width.

6 |
7 | 8 | - [contain](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#contain) 9 | -------------------------------------------------------------------------------- /plugins/plugin-contain/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-contain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-contain/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-cover/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-cover

5 |

Cover an image within a height and width.

6 |
7 | 8 | - [cover](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#cover) 9 | -------------------------------------------------------------------------------- /plugins/plugin-cover/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-cover/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-cover/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-crop/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-crop/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-crop

5 |

Crop an image.

6 |
7 | 8 | - [crop](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#crop) 9 | - [autocrop](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#autocrop) 10 | -------------------------------------------------------------------------------- /plugins/plugin-crop/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-crop/src/__snapshots__/crop.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`crop > full height from left 1`] = ` 4 | Visualization: 5 | 6 | 7 | ◆ 8 | ◆▦ 9 | ◆ 10 | 11 | 12 | Data: 13 | 14 | 00-00-00⁰⁰ 00-00-00⁰⁰ 15 | 00-00-00⁰⁰ FF-FF-00ᶠᶠ 16 | FF-FF-00ᶠᶠ 80-80-80ᶠᶠ 17 | 00-00-00⁰⁰ FF-FF-00ᶠᶠ 18 | 00-00-00⁰⁰ 00-00-00⁰⁰ 19 | `; 20 | 21 | exports[`crop > full height from middle 1`] = ` 22 | Visualization: 23 | 24 | ◆◆ 25 | ▦▦ 26 | ▦▦ 27 | ▦▦ 28 | ◆◆ 29 | 30 | Data: 31 | 32 | FF-FF-00ᶠᶠ FF-FF-00ᶠᶠ 33 | 80-80-80ᶠᶠ 80-80-80ᶠᶠ 34 | 80-80-80ᶠᶠ 80-80-80ᶠᶠ 35 | 80-80-80ᶠᶠ 80-80-80ᶠᶠ 36 | FF-FF-00ᶠᶠ FF-FF-00ᶠᶠ 37 | `; 38 | 39 | exports[`crop > full height from right 1`] = ` 40 | Visualization: 41 | 42 | 43 | ◆ 44 | ▦◆ 45 | ◆ 46 | 47 | 48 | Data: 49 | 50 | 00-00-00⁰⁰ 00-00-00⁰⁰ 51 | FF-FF-00ᶠᶠ 00-00-00⁰⁰ 52 | 80-80-80ᶠᶠ FF-FF-00ᶠᶠ 53 | FF-FF-00ᶠᶠ 00-00-00⁰⁰ 54 | 00-00-00⁰⁰ 00-00-00⁰⁰ 55 | `; 56 | 57 | exports[`crop > full width from bottom 1`] = ` 58 | Visualization: 59 | 60 | ◆▦▦◆ 61 | ◆◆ 62 | 63 | Data: 64 | 65 | 00-00-00⁰⁰ FF-FF-00ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ FF-FF-00ᶠᶠ 00-00-00⁰⁰ 66 | 00-00-00⁰⁰ 00-00-00⁰⁰ FF-FF-00ᶠᶠ FF-FF-00ᶠᶠ 00-00-00⁰⁰ 00-00-00⁰⁰ 67 | `; 68 | 69 | exports[`crop > full width from middle 1`] = ` 70 | Visualization: 71 | 72 | ◆▦▦▦▦◆ 73 | ◆▦▦◆ 74 | 75 | Data: 76 | 77 | FF-FF-00ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ FF-FF-00ᶠᶠ 78 | 00-00-00⁰⁰ FF-FF-00ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ FF-FF-00ᶠᶠ 00-00-00⁰⁰ 79 | `; 80 | 81 | exports[`crop > full width from top 1`] = ` 82 | Visualization: 83 | 84 | ◆◆ 85 | ◆▦▦◆ 86 | 87 | Data: 88 | 89 | 00-00-00⁰⁰ 00-00-00⁰⁰ FF-FF-00ᶠᶠ FF-FF-00ᶠᶠ 00-00-00⁰⁰ 00-00-00⁰⁰ 90 | 00-00-00⁰⁰ FF-FF-00ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ FF-FF-00ᶠᶠ 00-00-00⁰⁰ 91 | `; 92 | -------------------------------------------------------------------------------- /plugins/plugin-crop/src/crop.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | import { makeTestImage } from "@jimp/test-utils"; 4 | 5 | import { methods as crop } from "./index.js"; 6 | 7 | const jimp = createJimp({ plugins: [crop], formats: [] }); 8 | 9 | describe("crop", () => { 10 | // 6x5 size 11 | const testImage = makeTestImage( 12 | " ◆◆ ", 13 | " ◆▦▦◆ ", 14 | "◆▦▦▦▦◆", 15 | " ◆▦▦◆ ", 16 | " ◆◆ ", 17 | ); 18 | 19 | test("full width from top", () => { 20 | expect( 21 | jimp.fromBitmap(testImage).crop({ x: 0, y: 0, w: 6, h: 2 }), 22 | ).toMatchSnapshot(); 23 | }); 24 | 25 | test("full width from bottom", () => { 26 | expect( 27 | jimp.fromBitmap(testImage).crop({ x: 0, y: 3, w: 6, h: 2 }), 28 | ).toMatchSnapshot(); 29 | }); 30 | 31 | test("full width from middle", () => { 32 | expect( 33 | jimp.fromBitmap(testImage).crop({ x: 0, y: 2, w: 6, h: 2 }), 34 | ).toMatchSnapshot(); 35 | }); 36 | 37 | test("full height from left", () => { 38 | expect( 39 | jimp.fromBitmap(testImage).crop({ x: 0, y: 0, w: 2, h: 5 }), 40 | ).toMatchSnapshot(); 41 | }); 42 | 43 | test("full height from right", () => { 44 | expect( 45 | jimp.fromBitmap(testImage).crop({ x: 4, y: 0, w: 2, h: 5 }), 46 | ).toMatchSnapshot(); 47 | }); 48 | 49 | test("full height from middle", () => { 50 | expect( 51 | jimp.fromBitmap(testImage).crop({ x: 2, y: 0, w: 2, h: 5 }), 52 | ).toMatchSnapshot(); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /plugins/plugin-crop/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-crop/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-displace/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-displace/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-displace

5 |

Displace an image.

6 |
7 | 8 | Displaces the image based on the provided displacement map 9 | 10 | - [displace](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#displace) 11 | -------------------------------------------------------------------------------- /plugins/plugin-displace/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-displace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/plugin-displace", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "build": "tshy", 11 | "dev": "tshy --watch", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "author": "Andrew Lisowski ", 15 | "license": "MIT", 16 | "dependencies": { 17 | "@jimp/types": "workspace:*", 18 | "@jimp/utils": "workspace:*", 19 | "zod": "^3.23.8" 20 | }, 21 | "devDependencies": { 22 | "@jimp/config-eslint": "workspace:*", 23 | "@jimp/config-typescript": "workspace:*", 24 | "eslint": "^9.9.1", 25 | "tshy": "^3.0.2", 26 | "typescript": "^5.5.4", 27 | "vitest": "^2.0.5" 28 | }, 29 | "tshy": { 30 | "exclude": [ 31 | "**/*.test.ts" 32 | ], 33 | "exports": { 34 | "./package.json": "./package.json", 35 | ".": "./src/index.ts" 36 | } 37 | }, 38 | "exports": { 39 | "./package.json": "./package.json", 40 | ".": { 41 | "import": { 42 | "types": "./dist/esm/index.d.ts", 43 | "default": "./dist/esm/index.js" 44 | }, 45 | "require": { 46 | "types": "./dist/commonjs/index.d.ts", 47 | "default": "./dist/commonjs/index.js" 48 | } 49 | } 50 | }, 51 | "main": "./dist/commonjs/index.js", 52 | "types": "./dist/commonjs/index.d.ts", 53 | "type": "module", 54 | "publishConfig": { 55 | "access": "public" 56 | }, 57 | "sideEffects": false, 58 | "module": "./dist/esm/index.js" 59 | } 60 | -------------------------------------------------------------------------------- /plugins/plugin-displace/src/index.ts: -------------------------------------------------------------------------------- 1 | import { JimpClass, JimpClassSchema } from "@jimp/types"; 2 | import { clone } from "@jimp/utils"; 3 | import { z } from "zod"; 4 | 5 | const DisplaceOptionsSchema = z.object({ 6 | /** the source Jimp instance */ 7 | map: JimpClassSchema, 8 | /** the maximum displacement value */ 9 | offset: z.number(), 10 | }); 11 | 12 | export type DisplaceOptions = z.infer; 13 | 14 | export const methods = { 15 | /** 16 | * Displaces the image based on the provided displacement map 17 | * @param map the source Jimp instance 18 | * @param offset 19 | * @example 20 | * ```ts 21 | * import { Jimp } from "jimp"; 22 | * 23 | * const image = await Jimp.read("test/image.png"); 24 | * const map = await Jimp.read("test/map.png"); 25 | * 26 | * image.displace(map, 10); 27 | * ``` 28 | */ 29 | displace(image: I, options: DisplaceOptions) { 30 | const { map, offset } = DisplaceOptionsSchema.parse(options); 31 | const source = clone(image); 32 | 33 | image.scan((x, y, idx) => { 34 | let displacement = (map.bitmap.data[idx]! / 256) * offset; 35 | displacement = Math.round(displacement); 36 | 37 | const ids = image.getPixelIndex(x + displacement, y); 38 | image.bitmap.data[ids] = source.bitmap.data[idx]!; 39 | image.bitmap.data[ids + 1] = source.bitmap.data[idx + 1]!; 40 | image.bitmap.data[ids + 2] = source.bitmap.data[idx + 2]!; 41 | }); 42 | 43 | return image; 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /plugins/plugin-displace/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-dither/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-dither

5 |

Apply a dither effect to an image.

6 |
7 | 8 | > Dither - is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. Dither is routinely used in processing of both digital audio and video data, and is often one of the last stages of mastering audio to a CD. 9 | 10 | - [dither](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#dither) 11 | -------------------------------------------------------------------------------- /plugins/plugin-dither/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-dither/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/plugin-dither", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "build": "tshy", 11 | "dev": "tshy --watch", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "author": "Andrew Lisowski ", 15 | "license": "MIT", 16 | "dependencies": { 17 | "@jimp/types": "workspace:*" 18 | }, 19 | "devDependencies": { 20 | "@jimp/config-eslint": "workspace:*", 21 | "@jimp/config-typescript": "workspace:*", 22 | "eslint": "^9.9.1", 23 | "tshy": "^3.0.2", 24 | "typescript": "^5.5.4", 25 | "vitest": "^2.0.5" 26 | }, 27 | "tshy": { 28 | "exclude": [ 29 | "**/*.test.ts" 30 | ], 31 | "exports": { 32 | "./package.json": "./package.json", 33 | ".": "./src/index.ts" 34 | } 35 | }, 36 | "exports": { 37 | "./package.json": "./package.json", 38 | ".": { 39 | "import": { 40 | "types": "./dist/esm/index.d.ts", 41 | "default": "./dist/esm/index.js" 42 | }, 43 | "require": { 44 | "types": "./dist/commonjs/index.d.ts", 45 | "default": "./dist/commonjs/index.js" 46 | } 47 | } 48 | }, 49 | "main": "./dist/commonjs/index.js", 50 | "types": "./dist/commonjs/index.d.ts", 51 | "type": "module", 52 | "publishConfig": { 53 | "access": "public" 54 | }, 55 | "sideEffects": false, 56 | "module": "./dist/esm/index.js" 57 | } 58 | -------------------------------------------------------------------------------- /plugins/plugin-dither/src/index.ts: -------------------------------------------------------------------------------- 1 | import { JimpClass } from "@jimp/types"; 2 | 3 | export const methods = { 4 | /** 5 | * Apply a ordered dithering effect. 6 | * @example 7 | * ```ts 8 | * import { Jimp } from "jimp"; 9 | * 10 | * const image = await Jimp.read("test/image.png"); 11 | * 12 | * image.dither(); 13 | * ``` 14 | */ 15 | dither(image: I) { 16 | const rgb565Matrix = [ 17 | 1, 9, 3, 11, 13, 5, 15, 7, 4, 12, 2, 10, 16, 8, 14, 6, 18 | ]; 19 | 20 | image.scan((x, y, idx) => { 21 | const thresholdId = ((y & 3) << 2) + (x % 4); 22 | const dither = rgb565Matrix[thresholdId]!; 23 | 24 | image.bitmap.data[idx] = Math.min(image.bitmap.data[idx]! + dither, 0xff); 25 | image.bitmap.data[idx + 1] = Math.min( 26 | image.bitmap.data[idx + 1]! + dither, 27 | 0xff, 28 | ); 29 | image.bitmap.data[idx + 2] = Math.min( 30 | image.bitmap.data[idx + 2]! + dither, 31 | 0xff, 32 | ); 33 | }); 34 | 35 | return image; 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /plugins/plugin-dither/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-fisheye/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-fisheye/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-fisheye

5 |

Apply a fisheye effect to an image

6 |
7 | 8 | - [fisheye](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#fisheye) 9 | -------------------------------------------------------------------------------- /plugins/plugin-fisheye/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-fisheye/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | 3 | import { makeTestImage } from "@jimp/test-utils"; 4 | import { createJimp } from "@jimp/core"; 5 | 6 | import { methods } from "./index.js"; 7 | 8 | const Jimp = createJimp({ plugins: [methods] }); 9 | 10 | describe("Fisheye", () => { 11 | test("should create fisheye lens to image", () => { 12 | const img = Jimp.fromBitmap( 13 | makeTestImage( 14 | "0000000000", 15 | "0001221000", 16 | "0022222200", 17 | "0122112210", 18 | "0221001220", 19 | "0221001220", 20 | "0122112210", 21 | "0022222200", 22 | "0001221000", 23 | "0000000000", 24 | ), 25 | ); 26 | 27 | expect(img.fisheye()).toMatchSnapshot(); 28 | }); 29 | 30 | test("should create fisheye lens to image with radius", async () => { 31 | const imgNormal = Jimp.fromBitmap( 32 | makeTestImage( 33 | "0000000000", 34 | "0000000000", 35 | "0000000000", 36 | "0000000000", 37 | "0001111000", 38 | "0001111000", 39 | "0000000000", 40 | "0000000000", 41 | "0000000000", 42 | "0000000000", 43 | ), 44 | ); 45 | 46 | expect(imgNormal.fisheye({ radius: 1.8 })).toMatchSnapshot(); 47 | }); 48 | }); 49 | -------------------------------------------------------------------------------- /plugins/plugin-fisheye/src/index.ts: -------------------------------------------------------------------------------- 1 | import { JimpClass } from "@jimp/types"; 2 | import { clone } from "@jimp/utils"; 3 | import { z } from "zod"; 4 | 5 | const FisheyeOptionsSchema = z.object({ 6 | /** the radius of the circle */ 7 | radius: z.number().min(0).optional(), 8 | }); 9 | 10 | export type FisheyeOptions = z.infer; 11 | 12 | export const methods = { 13 | /** 14 | * Adds a fisheye effect to the image. 15 | * @example 16 | * ```ts 17 | * import { Jimp } from "jimp"; 18 | * 19 | * const image = await Jimp.read("test/image.png"); 20 | * 21 | * image.fisheye(); 22 | * ``` 23 | */ 24 | fisheye(image: I, options: FisheyeOptions = {}) { 25 | const { radius = 2.5 } = FisheyeOptionsSchema.parse(options); 26 | const source = clone(image); 27 | const { width, height } = source.bitmap; 28 | 29 | source.scan((x, y) => { 30 | const hx = x / width; 31 | const hy = y / height; 32 | const rActual = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2)); 33 | const rn = 2 * Math.pow(rActual, radius); 34 | const cosA = (hx - 0.5) / rActual; 35 | const sinA = (hy - 0.5) / rActual; 36 | const newX = Math.round((rn * cosA + 0.5) * width); 37 | const newY = Math.round((rn * sinA + 0.5) * height); 38 | const color = source.getPixelColor(newX, newY); 39 | 40 | image.setPixelColor(color, x, y); 41 | }); 42 | 43 | /* Set center pixel color, otherwise it will be transparent */ 44 | image.setPixelColor( 45 | source.getPixelColor(width / 2, height / 2), 46 | width / 2, 47 | height / 2, 48 | ); 49 | 50 | return image; 51 | }, 52 | }; 53 | -------------------------------------------------------------------------------- /plugins/plugin-fisheye/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-fisheye/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-flip/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-flip/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-flip

5 |

flip an image.

6 |
7 | 8 | Flip the image horizontally or vertically. Defaults to horizontal. 9 | 10 | Also aliased as `mirror` 11 | 12 | - [flip](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#flip) 13 | - [mirror](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#mirror) 14 | -------------------------------------------------------------------------------- /plugins/plugin-flip/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-flip/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test } from "vitest"; 2 | import { createJimp } from "@jimp/core"; 3 | import { makeTestImage } from "@jimp/test-utils"; 4 | 5 | import { methods } from "./index.js"; 6 | 7 | const jimp = createJimp({ plugins: [methods] }); 8 | 9 | describe("Flipping plugin", () => { 10 | test("can flip horizontally", () => { 11 | const src = jimp.fromBitmap( 12 | makeTestImage( 13 | "AAAABBBB", 14 | "AAABAAAB", 15 | "ABABABAB", 16 | "CCCCCCCC", 17 | "CCCCCCCC", 18 | "CCCCCCCC", 19 | "AACCCCAA", 20 | ), 21 | ); 22 | 23 | expect(src.flip({ horizontal: true })).toMatchSnapshot(); 24 | }); 25 | 26 | test("can flip vertically", () => { 27 | const src = jimp.fromBitmap( 28 | makeTestImage( 29 | "AAAABBBB", 30 | "AAABAAAB", 31 | "ABABABAB", 32 | "CCCCCCCC", 33 | "CCCCCCCC", 34 | "CCCCCCCC", 35 | "AACCCCAA", 36 | ), 37 | ); 38 | 39 | expect(src.flip({ vertical: true })).toMatchSnapshot(); 40 | }); 41 | 42 | test("can flip both horizontally and vertically at once", async () => { 43 | const src = jimp.fromBitmap( 44 | makeTestImage( 45 | "AAAABBBB", 46 | "AAABAAAB", 47 | "ABABABAB", 48 | "CCCCCCCC", 49 | "CCCCCCCC", 50 | "CCCCCCCC", 51 | "AACCCCAA", 52 | ), 53 | ); 54 | 55 | expect(src.flip({ horizontal: true, vertical: true })).toMatchSnapshot(); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /plugins/plugin-flip/src/index.ts: -------------------------------------------------------------------------------- 1 | import { JimpClass } from "@jimp/types"; 2 | import { z } from "zod"; 3 | 4 | const FlipOptionsSchema = z.object({ 5 | /** if true the image will be flipped horizontally */ 6 | horizontal: z.boolean().optional(), 7 | /** if true the image will be flipped vertically */ 8 | vertical: z.boolean().optional(), 9 | }); 10 | 11 | export type FlipOptions = z.infer; 12 | 13 | export const methods = { 14 | /** 15 | * Flip the image. 16 | * @param horizontal a Boolean, if true the image will be flipped horizontally 17 | * @param vertical a Boolean, if true the image will be flipped vertically 18 | * @example 19 | * ```ts 20 | * import { Jimp } from "jimp"; 21 | * 22 | * const image = await Jimp.read("test/image.png"); 23 | * 24 | * image.flip(true, false); 25 | * ``` 26 | */ 27 | flip(image: I, options: FlipOptions) { 28 | const { horizontal, vertical } = FlipOptionsSchema.parse(options); 29 | const bitmap = Buffer.alloc(image.bitmap.data.length); 30 | 31 | image.scan((x, y, idx) => { 32 | const _x = horizontal ? image.bitmap.width - 1 - x : x; 33 | const _y = vertical ? image.bitmap.height - 1 - y : y; 34 | const _idx = (image.bitmap.width * _y + _x) << 2; 35 | const data = image.bitmap.data.readUInt32BE(idx); 36 | 37 | bitmap.writeUInt32BE(data, _idx); 38 | }); 39 | 40 | image.bitmap.data = Buffer.from(bitmap); 41 | 42 | return image; 43 | }, 44 | }; 45 | -------------------------------------------------------------------------------- /plugins/plugin-flip/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-flip/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-hash/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.0.5 (Sun Sep 01 2024) 14 | 15 | #### 🐛 Bug Fix 16 | 17 | - add missing dependency [#1306](https://github.com/jimp-dev/jimp/pull/1306) ([@benmccann](https://github.com/benmccann) [@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | 19 | #### Authors: 2 20 | 21 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 22 | - Ben McCann ([@benmccann](https://github.com/benmccann)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-hash/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-hash/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-hash/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-mask/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-mask/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-mask

5 |

mask an image with another image.

6 |
7 | 8 | Masks a source image on to this image using average pixel colour. A completely black pixel on the mask will turn a pixel in the image completely transparent. 9 | 10 | - [mask](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#mask) 11 | -------------------------------------------------------------------------------- /plugins/plugin-mask/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-mask/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-mask/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-print/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/core

5 |
6 | 7 | The main Jimp class. This class can be extended with types and bitmap manipulation functions. Out of the box it does not support any image type. 8 | 9 | - [print](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#print) 10 | - [loadFont](http://jimp-dev.github.io/jimp/api/jimp/functions/loadfont/) 11 | -------------------------------------------------------------------------------- /plugins/plugin-print/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-10-black/open-sans-10-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-10-black/open-sans-10-black.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-12-black/open-sans-12-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-12-black/open-sans-12-black.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-128-black/open-sans-128-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-128-black/open-sans-128-black.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-128-white/open-sans-128-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-128-white/open-sans-128-white.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-14-black/open-sans-14-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-14-black/open-sans-14-black.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-16-black/open-sans-16-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-16-black/open-sans-16-black.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-16-white/open-sans-16-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-16-white/open-sans-16-white.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-32-black/open-sans-32-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-32-black/open-sans-32-black.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-32-white/open-sans-32-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-32-white/open-sans-32-white.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-64-black/open-sans-64-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-64-black/open-sans-64-black.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-64-white/open-sans-64-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-64-white/open-sans-64-white.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-8-black/open-sans-8-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-8-black/open-sans-8-black.png -------------------------------------------------------------------------------- /plugins/plugin-print/fonts/open-sans/open-sans-8-white/open-sans-8-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/fonts/open-sans/open-sans-8-white/open-sans-8-white.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-bottom-align-text-when-passing-object-with-alignment-y-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-bottom-align-text-when-passing-object-with-alignment-y-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-bottom-align-text-when-passing-object-with-alignment-y-offset-y-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-bottom-align-text-when-passing-object-with-alignment-y-offset-y-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-center-align-text-when-passing-object-with-alignment-x-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-center-align-text-when-passing-object-with-alignment-x-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-exposes-print-y-position-in-cb-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-exposes-print-y-position-in-cb-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-can-print-numbers-too-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-can-print-numbers-too-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-loads-font-from-url-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-loads-font-from-url-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-16-black-bitmap-font-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-16-black-bitmap-font-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-16-black-bitmap-font-positioned-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-16-black-bitmap-font-positioned-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-16-white-bitmap-font-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-16-white-bitmap-font-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-32-black-bitmap-font-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-32-black-bitmap-font-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-32-white-bitmap-font-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-32-white-bitmap-font-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-64-black-bitmap-font-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-64-black-bitmap-font-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-64-white-bitmap-font-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-64-white-bitmap-font-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-8-black-bitmap-font-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-8-black-bitmap-font-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-8-white-bitmap-font-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-preset-sans-8-white-bitmap-font-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-renders-for-unknown-characters-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-jimp-renders-for-unknown-characters-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-left-align-text-by-default-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-left-align-text-by-default-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-left-align-text-by-default-when-passing-object-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-left-align-text-by-default-when-passing-object-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-left-align-text-when-passing-object-with-alignment-x-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-left-align-text-when-passing-object-with-alignment-x-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-max-width-works-without-spaces-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-max-width-works-without-spaces-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-middle-align-text-when-passing-object-with-alignment-y-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-middle-align-text-when-passing-object-with-alignment-y-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-middle-align-text-when-passing-object-with-alignment-y-can-offset-y-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-middle-align-text-when-passing-object-with-alignment-y-can-offset-y-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-right-align-text-when-passing-object-with-alignment-x-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-right-align-text-when-passing-object-with-alignment-x-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-text-with-newlines-default-alignment-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-print/src/__image_snapshots__/index-node-test-ts-write-text-over-image-text-with-newlines-default-alignment-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-print/src/dirname-cjs.cts: -------------------------------------------------------------------------------- 1 | export const dirname = __dirname; 2 | -------------------------------------------------------------------------------- /plugins/plugin-print/src/dirname.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath } from "url"; 2 | import path from "path"; 3 | 4 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 5 | // @ts-ignore Dual package 6 | export const dirname = path.dirname(fileURLToPath(import.meta.url)); 7 | -------------------------------------------------------------------------------- /plugins/plugin-print/src/load-font.ts: -------------------------------------------------------------------------------- 1 | import { 2 | isWebWorker, 3 | loadBitmapFontData, 4 | processBitmapFont, 5 | } from "./load-bitmap-font.js"; 6 | 7 | /** 8 | * Loads a Bitmap Font from a file. 9 | * @param file A path or URL to a font file 10 | * @returns A collection of Jimp images that can be used to print text 11 | * @example 12 | * ```ts 13 | * import { Jimp, loadFont } from "jimp"; 14 | * import { SANS_10_BLACK } from "jimp/fonts"; 15 | * 16 | * const font = await loadFont(SANS_10_BLACK); 17 | * const image = new Jimp({ width: 200, height: 100, color: 0xffffffff }); 18 | * 19 | * image.print(font, 10, 10, "Hello world!"); 20 | * ``` 21 | */ 22 | export async function loadFont(file: string) { 23 | let fileOrBuffer: string | Buffer = file; 24 | 25 | if (typeof window === "undefined" && !isWebWorker) { 26 | const { existsSync, promises: fs } = await import("fs"); 27 | 28 | if (existsSync(file)) { 29 | fileOrBuffer = await fs.readFile(file); 30 | } 31 | } 32 | 33 | const data = await loadBitmapFontData(fileOrBuffer); 34 | return processBitmapFont(file, data); 35 | } 36 | -------------------------------------------------------------------------------- /plugins/plugin-print/src/types.ts: -------------------------------------------------------------------------------- 1 | import { JimpClass } from "@jimp/types"; 2 | 3 | export interface BmCharacter { 4 | id: number; 5 | xadvance: number; 6 | width: number; 7 | height: number; 8 | xoffset: number; 9 | yoffset: number; 10 | page: number; 11 | x: number; 12 | y: number; 13 | } 14 | 15 | export interface BmKerning { 16 | [secondString: string]: number; 17 | first: number; 18 | second: number; 19 | amount: number; 20 | } 21 | 22 | export interface BmCommonProps { 23 | lineHeight: number; 24 | } 25 | 26 | export interface BmFont { 27 | chars: Record; 28 | kernings: Record; 29 | common: BmCommonProps; 30 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 31 | info: Record; 32 | pages: T[]; 33 | } 34 | -------------------------------------------------------------------------------- /plugins/plugin-print/src/types/parse-bmfont-ascii.d.ts: -------------------------------------------------------------------------------- 1 | declare module "parse-bmfont-ascii" { 2 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 3 | export default function parseASCII(data: string): any; 4 | } 5 | -------------------------------------------------------------------------------- /plugins/plugin-print/src/types/parse-bmfont-binary.d.ts: -------------------------------------------------------------------------------- 1 | declare module "parse-bmfont-binary" { 2 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 3 | export default function readBinary(data: Buffer): any; 4 | } 5 | -------------------------------------------------------------------------------- /plugins/plugin-print/src/types/parse-bmfont-xml.d.ts: -------------------------------------------------------------------------------- 1 | declare module "parse-bmfont-xml" { 2 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 3 | export default function parseXML(data: string): any; 4 | } 5 | -------------------------------------------------------------------------------- /plugins/plugin-print/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-quantize/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.4.0 (Sat Sep 07 2024) 2 | 3 | #### ⚠️ Pushed to `main` 4 | 5 | - fix docs build ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.3 (Mon Sep 02 2024) 14 | 15 | #### 🐛 Bug Fix 16 | 17 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | 19 | #### Authors: 1 20 | 21 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 22 | 23 | --- 24 | 25 | # v1.1.0 (Sun Sep 01 2024) 26 | 27 | #### 🚀 Enhancement 28 | 29 | - Add quantize plugin [#1307](https://github.com/jimp-dev/jimp/pull/1307) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 30 | 31 | #### Authors: 1 32 | 33 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 34 | -------------------------------------------------------------------------------- /plugins/plugin-quantize/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-quantize

5 |

Reduces the number of colors in an image.

6 |
7 | 8 | - [quantize](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#quantize) 9 | -------------------------------------------------------------------------------- /plugins/plugin-quantize/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-quantize/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/plugin-quantize", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "test": "vitest", 11 | "build": "tshy", 12 | "dev": "tshy --watch", 13 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 14 | }, 15 | "author": "Andrew Lisowski ", 16 | "license": "MIT", 17 | "devDependencies": { 18 | "@jimp/config-eslint": "workspace:*", 19 | "@jimp/config-typescript": "workspace:*", 20 | "@jimp/core": "workspace:*", 21 | "@jimp/js-jpeg": "workspace:*", 22 | "@jimp/js-png": "workspace:*", 23 | "@jimp/test-utils": "workspace:*", 24 | "@jimp/types": "workspace:*", 25 | "eslint": "^9.9.1", 26 | "tshy": "^3.0.2", 27 | "typescript": "^5.5.4", 28 | "vite-plugin-node-polyfills": "^0.22.0", 29 | "vitest": "^2.0.5" 30 | }, 31 | "tshy": { 32 | "exclude": [ 33 | "**/*.test.ts" 34 | ], 35 | "exports": { 36 | "./package.json": "./package.json", 37 | ".": "./src/index.ts" 38 | } 39 | }, 40 | "exports": { 41 | "./package.json": "./package.json", 42 | ".": { 43 | "import": { 44 | "types": "./dist/esm/index.d.ts", 45 | "default": "./dist/esm/index.js" 46 | }, 47 | "require": { 48 | "types": "./dist/commonjs/index.d.ts", 49 | "default": "./dist/commonjs/index.js" 50 | } 51 | } 52 | }, 53 | "main": "./dist/commonjs/index.js", 54 | "types": "./dist/commonjs/index.d.ts", 55 | "type": "module", 56 | "publishConfig": { 57 | "access": "public" 58 | }, 59 | "sideEffects": false, 60 | "dependencies": { 61 | "image-q": "^4.0.0", 62 | "zod": "^3.23.8" 63 | }, 64 | "module": "./dist/esm/index.js" 65 | } 66 | -------------------------------------------------------------------------------- /plugins/plugin-quantize/src/__image_snapshots__/index-node-test-ts-quantize-defines-default-threshold-for-lighter-backgrounds-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-quantize/src/__image_snapshots__/index-node-test-ts-quantize-defines-default-threshold-for-lighter-backgrounds-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-quantize/src/images/colorful.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-quantize/src/images/colorful.png -------------------------------------------------------------------------------- /plugins/plugin-quantize/src/index.node.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import "@jimp/test-utils"; 3 | import "@jimp/test-utils/image-snapshot"; 4 | 5 | import png from "@jimp/js-png"; 6 | import { createJimp } from "@jimp/core"; 7 | 8 | import { methods as quantize } from "./index.js"; 9 | 10 | const jimp = createJimp({ formats: [png], plugins: [quantize] }); 11 | 12 | describe("Quantize", () => { 13 | test("defines default threshold for lighter backgrounds", async () => { 14 | const testImage = await jimp.read(__dirname + "/images/colorful.png"); 15 | const output = await testImage 16 | .quantize({ 17 | colors: 8, 18 | }) 19 | .getBuffer("image/png"); 20 | 21 | expect(output).toMatchImageSnapshot(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /plugins/plugin-quantize/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-resize/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-resize/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-resize

5 |

Resize an image.

6 |
7 | 8 | Resizes the image to a set width and height using a 2-pass bilinear algorithm. 9 | 10 | - [resize](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#resize) 11 | - [scale](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#scale) 12 | - [scaleToFit](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#scaletofit) 13 | -------------------------------------------------------------------------------- /plugins/plugin-resize/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-resize/src/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * What resizing algorithm to use. 3 | */ 4 | export enum ResizeStrategy { 5 | /** 6 | * Nearest Neighbor resizing is a method used in image processing that assigns the value of the nearest pixel to the output pixel when resizing an image. 7 | * While fast, it can lead to lower quality outputs with noticeable pixelation, especially at larger scaling factors. 8 | */ 9 | NEAREST_NEIGHBOR = "nearestNeighbor", 10 | /** 11 | * Bilinear resizing is an image scaling method that uses the weighted average of the four nearest pixel values, providing smoother gradients than nearest neighbor resizing. 12 | * It's computationally more intense than nearest neighbor but results in images of higher quality and fewer artifacts. 13 | */ 14 | BILINEAR = "bilinearInterpolation", 15 | /** 16 | * Bicubic resizing is an image interpolation method that uses the values of the nearest 16 pixels in the input image to calculate the output pixel value, providing even more smoothness and sharpness than bilinear resizing. 17 | * Although it's computationally more expensive than bilinear and nearest neighbor, it produces higher quality images, making it ideal for photographic image scaling. 18 | */ 19 | BICUBIC = "bicubicInterpolation", 20 | /** 21 | * Hermite resizing is an image resizing method that uses Hermite interpolation, a mathematical formula, to determine the values of output pixels based on a weighted average of the surrounding pixels. 22 | * Although slower than some simpler techniques like bilinear or nearest neighbor, Hermite resizing can produce higher quality visuals and detailed renderings with less blurring. 23 | */ 24 | HERMITE = "hermiteInterpolation", 25 | BEZIER = "bezierInterpolation", 26 | } 27 | -------------------------------------------------------------------------------- /plugins/plugin-resize/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-resize/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-rotate/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-rotate

5 |

Rotate an image.

6 |
7 | 8 | Rotates the image counter-clockwise by a number of degrees. By default the width and height of the image will be resized appropriately. 9 | 10 | - [rotate](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#rotate) 11 | -------------------------------------------------------------------------------- /plugins/plugin-rotate/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-rotate/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-rotate/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-shadow/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-shadow

5 |

Creates a shadow on an image.

6 |
7 | 8 | - [shadow](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#shadow) 9 | -------------------------------------------------------------------------------- /plugins/plugin-shadow/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-shadow/src/__snapshots__/index.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`Shadow > creates a shadow 1`] = ` 4 | Visualization: 5 | 6 | 7 | 0▱▥1▪◇▫ 8 | ▪ED▥93F5▫ 9 | ▰C7▸◇▥▵□A1 10 | F◇▦▾2A651▫ 11 | ◆■B■■3F6▰▰ 12 | E▱▥!▸0■D6▫ 13 | 14 | Data: 15 | 16 | 00-00-00⁰⁰ 00-00-00⁰⁰ 00-00-00⁰⁰ 00-00-00⁰⁰ 00-00-00⁰⁰ 00-00-00⁰⁰ 00-00-00⁰⁰ 00-00-00⁰⁰ 00-00-00⁰⁰ 00-00-00⁰⁰ 17 | 00-00-00⁰⁰ 04-04-00⁰² 0F-0F-00⁰ᵇ 20-20-02¹⁷ E4-E4-00ᶠᶠ E5-E5-00ᶠᶠ 18-18-01¹² 09-09-00⁰⁶ 00-00-00⁰⁰ 00-00-00⁰⁰ 18 | 03-03-00⁰² 0D-0D-01⁰ᵃ 22-22-05¹ᶜ D8-D8-02ᶠᶠ 73-73-63ᶠᶠ 72-72-64ᶠᶠ DD-DD-01ᶠᶠ 18-18-03¹³ 07-07-00⁰⁵ 00-00-00⁰⁰ 19 | 0B-0B-00⁰⁸ 20-20-05¹ᵃ D4-D4-03ᶠᶠ 75-75-5Dᶠᶠ 7C-7C-59ᶠᶠ 7A-7A-5Aᶠᶠ 73-73-60ᶠᶠ DB-DB-01ᶠᶠ 16-16-02¹⁰ 06-06-00⁰⁴ 20 | 13-13-01⁰ᵉ 33-33-08²ᵃ 5D-5D-1A⁵⁴ C0-C0-19ᶠᶠ 89-89-5Dᶠᶠ 87-87-5Cᶠᶠ C2-C2-12ᶠᶠ 4E-4E-11⁴³ 25-25-04¹ᶜ 0B-0B-00⁰⁷ 21 | 16-16-01¹⁰ 3A-3A-0A²ᶠ 65-65-1D⁵ᶜ 87-87-3A⁸⁷ BE-BE-30ᶠᶠ BE-BE-2Bᶠᶠ 7F-7F-2F⁷ᵃ 56-56-14⁴ᵃ 2A-2A-04²⁰ 0D-0D-00⁰⁹ 22 | 0F-0F-01⁰ᵇ 2C-2C-07²⁴ 54-54-16⁴ᵃ 78-78-2D⁷³ 8B-8B-3C⁸ᵇ 87-87-38⁸⁶ 6E-6E-24⁶⁶ 45-45-0F³ᵃ 1E-1E-03¹⁷ 09-09-00⁰⁶ 23 | `; 24 | -------------------------------------------------------------------------------- /plugins/plugin-shadow/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | 3 | import { makeTestImage } from "@jimp/test-utils"; 4 | 5 | import { methods } from "./index.js"; 6 | import { createJimp } from "@jimp/core"; 7 | 8 | const jimp = createJimp({ plugins: [methods] }); 9 | 10 | describe("Shadow", () => { 11 | test("creates a shadow", async () => { 12 | const testImage = jimp.fromBitmap( 13 | makeTestImage( 14 | " ", 15 | " ◆◆ ", 16 | " ◆▦▦◆ ", 17 | " ◆▦▦▦▦◆ ", 18 | " ◆▦▦◆ ", 19 | " ◆◆ ", 20 | " ", 21 | ), 22 | ); 23 | 24 | expect(testImage.shadow({ x: -1, y: 1, blur: 1 })).toMatchSnapshot(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /plugins/plugin-shadow/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-shadow/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/plugin-threshold/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.3 (Mon Sep 02 2024) 2 | 3 | #### 🐛 Bug Fix 4 | 5 | - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Sun Sep 01 2024) 14 | 15 | #### ⚠️ Pushed to `main` 16 | 17 | - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie)) 19 | 20 | #### Authors: 1 21 | 22 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 23 | 24 | --- 25 | 26 | # v1.0.3 (Sat Aug 31 2024) 27 | 28 | #### 🐛 Bug Fix 29 | 30 | - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 31 | 32 | #### ⚠️ Pushed to `main` 33 | 34 | - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie)) 35 | 36 | #### Authors: 1 37 | 38 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 39 | 40 | --- 41 | 42 | # v1.0.2 (Sat Aug 31 2024) 43 | 44 | #### ⚠️ Pushed to `main` 45 | 46 | - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie)) 47 | - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie)) 48 | - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie)) 49 | 50 | #### Authors: 1 51 | 52 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 53 | -------------------------------------------------------------------------------- /plugins/plugin-threshold/README.md: -------------------------------------------------------------------------------- 1 |
2 | 4 |

@jimp/plugin-threshold

5 |

Lightens an image.

6 |
7 | 8 | This is useful as a simplified method for processing scanned drawings, signatures, etc 9 | 10 | - [threshold](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#threshold) 11 | -------------------------------------------------------------------------------- /plugins/plugin-threshold/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/plugin-threshold/src/__image_snapshots__/index-test-ts-src-index-test-ts-threshold-defines-default-threshold-for-lighter-backgrounds-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/plugin-threshold/src/__image_snapshots__/index-test-ts-src-index-test-ts-threshold-defines-default-threshold-for-lighter-backgrounds-1-snap.png -------------------------------------------------------------------------------- /plugins/plugin-threshold/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, describe } from "vitest"; 2 | import "@jimp/test-utils"; 3 | 4 | import jpeg from "@jimp/js-jpeg"; 5 | import { methods as hash } from "@jimp/plugin-hash"; 6 | import { createJimp } from "@jimp/core"; 7 | 8 | import { methods as threshold } from "./index.js"; 9 | import { getTestImagePath } from "@jimp/test-utils"; 10 | 11 | const jimp = createJimp({ formats: [jpeg], plugins: [threshold, hash] }); 12 | 13 | describe("Threshold", () => { 14 | test("defines default threshold for lighter backgrounds", async () => { 15 | const testImage = await jimp.read(getTestImagePath("hands.jpg")); 16 | const expectedImage = await jimp.read( 17 | getTestImagePath("hands_mx200_rp255.jpg"), 18 | ); 19 | const output = testImage.threshold({ max: 200, replace: 255 }).hash(); 20 | 21 | expect(output).toStrictEqual(expectedImage.hash()); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /plugins/plugin-threshold/src/index.ts: -------------------------------------------------------------------------------- 1 | import { JimpClass } from "@jimp/types"; 2 | import { limit255 } from "@jimp/utils"; 3 | import { methods as color } from "@jimp/plugin-color"; 4 | import { z } from "zod"; 5 | 6 | const ThresholdOptionsSchema = z.object({ 7 | /** A number auto limited between 0 - 255 */ 8 | max: z.number().min(0).max(255), 9 | /** A number auto limited between 0 - 255 (default 255) */ 10 | replace: z.number().min(0).max(255).optional(), 11 | /** A boolean whether to apply greyscale beforehand (default true) */ 12 | autoGreyscale: z.boolean().optional(), 13 | }); 14 | 15 | export type ThresholdOptions = z.infer; 16 | 17 | export const methods = { 18 | /** 19 | * Applies a minimum color threshold to a grayscale image. 20 | * Converts image to grayscale by default. 21 | * @example 22 | * ```ts 23 | * import { Jimp } from "jimp"; 24 | * 25 | * const image = await Jimp.read("test/image.png"); 26 | * 27 | * image.threshold({ max: 150 }); 28 | * ``` 29 | */ 30 | threshold(image: I, options: ThresholdOptions) { 31 | let { 32 | max, 33 | replace = 255, 34 | // eslint-disable-next-line prefer-const 35 | autoGreyscale = true, 36 | } = ThresholdOptionsSchema.parse(options); 37 | 38 | max = limit255(max); 39 | replace = limit255(replace); 40 | 41 | if (autoGreyscale) { 42 | color.greyscale(image); 43 | } 44 | 45 | image.scan((_, __, idx) => { 46 | const grey = 47 | image.bitmap.data[idx]! < max ? image.bitmap.data[idx]! : replace; 48 | 49 | image.bitmap.data[idx] = grey; 50 | image.bitmap.data[idx + 1] = grey; 51 | image.bitmap.data[idx + 2] = grey; 52 | }); 53 | 54 | return image; 55 | }, 56 | }; 57 | -------------------------------------------------------------------------------- /plugins/plugin-threshold/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/plugin-threshold/vitest.config.browser.mjs: -------------------------------------------------------------------------------- 1 | import config from "@jimp/config-vitest/browser"; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /plugins/wasm-avif/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.0 (Tue Sep 03 2024) 2 | 3 | #### 🚀 Enhancement 4 | 5 | - Add webp, avid, png, jpeg WASM format plugin [#1324](https://github.com/jimp-dev/jimp/pull/1324) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | -------------------------------------------------------------------------------- /plugins/wasm-avif/README.md: -------------------------------------------------------------------------------- 1 | # `@jimp/wasm-avif` 2 | 3 | A format plugin for Jimp that adds support for AVIF images using the [libavif](https://github.com/AOMediaCodec/libavif). 4 | 5 | > NOTE: Only works in esm environments. 6 | 7 | ## Usage 8 | 9 | ```ts 10 | import { createJimp } from "@jimp/core"; 11 | import { defaultPlugins } from "jimp"; 12 | import avif from "@jimp/wasm-avif"; 13 | 14 | // A custom jimp that supports webp 15 | const Jimp = createJimp({ 16 | formats: [avif], 17 | plugins: defaultPlugins, 18 | }); 19 | ``` 20 | -------------------------------------------------------------------------------- /plugins/wasm-avif/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/wasm-avif/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/wasm-avif", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "build": "tshy", 11 | "dev": "tshy --watch", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "author": "Andrew Lisowski ", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@jimp/config-eslint": "workspace:*", 18 | "@jimp/config-typescript": "workspace:*", 19 | "@jimp/core": "workspace:*", 20 | "@jimp/plugin-color": "workspace:*", 21 | "@jimp/test-utils": "workspace:*", 22 | "@jimp/types": "workspace:*", 23 | "@types/node": "^18.19.48", 24 | "eslint": "^9.9.1", 25 | "tshy": "^3.0.2", 26 | "typescript": "^5.5.4", 27 | "vitest": "^2.0.5" 28 | }, 29 | "tshy": { 30 | "exclude": [ 31 | "**/*.test.ts" 32 | ], 33 | "dialects": [ 34 | "esm" 35 | ], 36 | "exports": { 37 | "./package.json": "./package.json", 38 | ".": "./src/index.ts" 39 | } 40 | }, 41 | "exports": { 42 | "./package.json": "./package.json", 43 | ".": { 44 | "import": { 45 | "types": "./dist/esm/index.d.ts", 46 | "default": "./dist/esm/index.js" 47 | } 48 | } 49 | }, 50 | "type": "module", 51 | "publishConfig": { 52 | "access": "public" 53 | }, 54 | "sideEffects": false, 55 | "dependencies": { 56 | "@jsquash/avif": "^1.3.0", 57 | "zod": "^3.23.8" 58 | }, 59 | "module": "./dist/esm/index.js" 60 | } 61 | -------------------------------------------------------------------------------- /plugins/wasm-avif/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/wasm-jpeg/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.0 (Tue Sep 03 2024) 2 | 3 | #### 🚀 Enhancement 4 | 5 | - Add webp, avid, png, jpeg WASM format plugin [#1324](https://github.com/jimp-dev/jimp/pull/1324) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | -------------------------------------------------------------------------------- /plugins/wasm-jpeg/README.md: -------------------------------------------------------------------------------- 1 | # `@jimp/wasm-jpeg` 2 | 3 | A format plugin for Jimp that adds support for JPEG images using [mozjpeg](https://github.com/mozilla/mozjpeg). 4 | 5 | > NOTE: Only works in esm environments. 6 | 7 | ## Usage 8 | 9 | ```ts 10 | import { createJimp } from "@jimp/core"; 11 | import { defaultPlugins } from "jimp"; 12 | import jpeg from "@jimp/wasm-jpeg"; 13 | 14 | // A custom jimp that supports webp 15 | const Jimp = createJimp({ 16 | formats: [jpeg], 17 | plugins: defaultPlugins, 18 | }); 19 | ``` 20 | -------------------------------------------------------------------------------- /plugins/wasm-jpeg/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/wasm-jpeg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/wasm-jpeg", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "build": "tshy", 11 | "dev": "tshy --watch", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "author": "Andrew Lisowski ", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@jimp/config-eslint": "workspace:*", 18 | "@jimp/config-typescript": "workspace:*", 19 | "@jimp/core": "workspace:*", 20 | "@jimp/plugin-color": "workspace:*", 21 | "@jimp/test-utils": "workspace:*", 22 | "@jimp/types": "workspace:*", 23 | "@types/node": "^18.19.48", 24 | "eslint": "^9.9.1", 25 | "tshy": "^3.0.2", 26 | "typescript": "^5.5.4", 27 | "vitest": "^2.0.5" 28 | }, 29 | "tshy": { 30 | "exclude": [ 31 | "**/*.test.ts" 32 | ], 33 | "dialects": [ 34 | "esm" 35 | ], 36 | "exports": { 37 | "./package.json": "./package.json", 38 | ".": "./src/index.ts" 39 | } 40 | }, 41 | "exports": { 42 | "./package.json": "./package.json", 43 | ".": { 44 | "import": { 45 | "types": "./dist/esm/index.d.ts", 46 | "default": "./dist/esm/index.js" 47 | } 48 | } 49 | }, 50 | "type": "module", 51 | "publishConfig": { 52 | "access": "public" 53 | }, 54 | "sideEffects": false, 55 | "dependencies": { 56 | "@jsquash/jpeg": "^1.4.0", 57 | "zod": "^3.23.8" 58 | }, 59 | "module": "./dist/esm/index.js" 60 | } 61 | -------------------------------------------------------------------------------- /plugins/wasm-jpeg/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/wasm-png/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.1.0 (Tue Sep 03 2024) 2 | 3 | #### 🚀 Enhancement 4 | 5 | - Add webp, avid, png, jpeg WASM format plugin [#1324](https://github.com/jimp-dev/jimp/pull/1324) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | -------------------------------------------------------------------------------- /plugins/wasm-png/README.md: -------------------------------------------------------------------------------- 1 | # `@jimp/wasm-png` 2 | 3 | A format plugin for Jimp that adds support for PNG images using the [rust crate](https://docs.rs/png/0.11.0/png/). 4 | It also support optimizing the image using [oxipng](https://github.com/shssoichiro/oxipng). 5 | 6 | > NOTE: Only works in esm environments. 7 | 8 | ## Usage 9 | 10 | ```ts 11 | import { createJimp } from "@jimp/core"; 12 | import { defaultPlugins } from "jimp"; 13 | import png from "@jimp/wasm-png"; 14 | 15 | // A custom jimp that supports webp 16 | const Jimp = createJimp({ 17 | formats: [png], 18 | plugins: defaultPlugins, 19 | }); 20 | ``` 21 | -------------------------------------------------------------------------------- /plugins/wasm-png/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/wasm-png/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/wasm-png", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "build": "tshy", 11 | "dev": "tshy --watch", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "author": "Andrew Lisowski ", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@jimp/config-eslint": "workspace:*", 18 | "@jimp/config-typescript": "workspace:*", 19 | "@jimp/core": "workspace:*", 20 | "@jimp/plugin-color": "workspace:*", 21 | "@jimp/test-utils": "workspace:*", 22 | "@jimp/types": "workspace:*", 23 | "@types/node": "^18.19.48", 24 | "eslint": "^9.9.1", 25 | "tshy": "^3.0.2", 26 | "typescript": "^5.5.4", 27 | "vitest": "^2.0.5" 28 | }, 29 | "tshy": { 30 | "exclude": [ 31 | "**/*.test.ts" 32 | ], 33 | "dialects": [ 34 | "esm" 35 | ], 36 | "exports": { 37 | "./package.json": "./package.json", 38 | ".": "./src/index.ts" 39 | } 40 | }, 41 | "exports": { 42 | "./package.json": "./package.json", 43 | ".": { 44 | "import": { 45 | "types": "./dist/esm/index.d.ts", 46 | "default": "./dist/esm/index.js" 47 | } 48 | } 49 | }, 50 | "type": "module", 51 | "publishConfig": { 52 | "access": "public" 53 | }, 54 | "sideEffects": false, 55 | "dependencies": { 56 | "@jsquash/oxipng": "^2.3.0", 57 | "@jsquash/png": "^3.0.1", 58 | "zod": "^3.23.8" 59 | }, 60 | "module": "./dist/esm/index.js" 61 | } 62 | -------------------------------------------------------------------------------- /plugins/wasm-png/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /plugins/wasm-webp/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.4.0 (Sat Sep 07 2024) 2 | 3 | #### ⚠️ Pushed to `main` 4 | 5 | - fix docs build ([@hipstersmoothie](https://github.com/hipstersmoothie)) 6 | 7 | #### Authors: 1 8 | 9 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 10 | 11 | --- 12 | 13 | # v1.1.0 (Tue Sep 03 2024) 14 | 15 | #### 🚀 Enhancement 16 | 17 | - Add webp, avid, png, jpeg WASM format plugin [#1324](https://github.com/jimp-dev/jimp/pull/1324) ([@hipstersmoothie](https://github.com/hipstersmoothie)) 18 | 19 | #### Authors: 1 20 | 21 | - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) 22 | -------------------------------------------------------------------------------- /plugins/wasm-webp/README.md: -------------------------------------------------------------------------------- 1 | # `@jimp/wasm-webp` 2 | 3 | A format plugin for Jimp that adds support for WebP images. 4 | 5 | > NOTE: Only works in esm environments. 6 | 7 | ## Usage 8 | 9 | ```ts 10 | import { createJimp } from "@jimp/core"; 11 | import { defaultFormats, defaultPlugins } from "jimp"; 12 | import webp from "@jimp/wasm-webp"; 13 | 14 | // A custom jimp that supports webp 15 | const Jimp = createJimp({ 16 | formats: [...defaultFormats, webp], 17 | plugins: defaultPlugins, 18 | }); 19 | ``` 20 | -------------------------------------------------------------------------------- /plugins/wasm-webp/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /plugins/wasm-webp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/wasm-webp", 3 | "version": "1.6.0", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "build": "tshy", 11 | "dev": "tshy --watch", 12 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 13 | }, 14 | "author": "Andrew Lisowski ", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@jimp/config-eslint": "workspace:*", 18 | "@jimp/config-typescript": "workspace:*", 19 | "@jimp/core": "workspace:*", 20 | "@jimp/plugin-color": "workspace:*", 21 | "@jimp/test-utils": "workspace:*", 22 | "@jimp/types": "workspace:*", 23 | "@types/node": "^18.19.48", 24 | "eslint": "^9.9.1", 25 | "tshy": "^3.0.2", 26 | "typescript": "^5.5.4", 27 | "vite-plugin-node-polyfills": "^0.22.0", 28 | "vitest": "^2.0.5" 29 | }, 30 | "tshy": { 31 | "exclude": [ 32 | "**/*.test.ts" 33 | ], 34 | "dialects": [ 35 | "esm" 36 | ], 37 | "exports": { 38 | "./package.json": "./package.json", 39 | ".": "./src/index.ts" 40 | } 41 | }, 42 | "exports": { 43 | "./package.json": "./package.json", 44 | ".": { 45 | "import": { 46 | "types": "./dist/esm/index.d.ts", 47 | "default": "./dist/esm/index.js" 48 | } 49 | } 50 | }, 51 | "type": "module", 52 | "publishConfig": { 53 | "access": "public" 54 | }, 55 | "sideEffects": false, 56 | "dependencies": { 57 | "@jsquash/webp": "^1.4.0", 58 | "zod": "^3.23.8" 59 | }, 60 | "module": "./dist/esm/index.js" 61 | } 62 | -------------------------------------------------------------------------------- /plugins/wasm-webp/src/images/test.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimp-dev/jimp/b6b0e418a5f1259211a133b20cddb4f4e5c25679/plugins/wasm-webp/src/images/test.webp -------------------------------------------------------------------------------- /plugins/wasm-webp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - "packages/*" 3 | - "plugins/*" 4 | -------------------------------------------------------------------------------- /refactor.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | 4 | function addPublishConfigToPackageJson(directory) { 5 | fs.readdirSync(directory, { withFileTypes: true }).forEach((entry) => { 6 | const fullPath = path.join(directory, entry.name); 7 | if (entry.isDirectory()) { 8 | addPublishConfigToPackageJson(fullPath); 9 | } else if (entry.isFile() && entry.name === ".eslintrc.mjs") { 10 | fs.unlinkSync(fullPath); 11 | const dir = path.dirname(fullPath); 12 | fs.writeFileSync( 13 | path.join(dir, "eslint.config.mjs"), 14 | `import shared from "@jimp/config-eslint/base.js";\nexport default [...shared];` 15 | ); 16 | } 17 | }); 18 | } 19 | 20 | // Run the script in the current directory 21 | addPublishConfigToPackageJson("."); 22 | 23 | console.log("Package.json updates complete."); 24 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const anyBase = require("any-base"); 2 | 3 | const alphabet = 4 | "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_"; 5 | 6 | // an array storing the maximum string length of hashes at various bases 7 | // 0 and 1 do not exist as possible hash lengths 8 | const maxHashLength = [NaN, NaN]; 9 | 10 | for (let i = 2; i < 65; i++) { 11 | const maxHash = anyBase( 12 | anyBase.BIN, 13 | alphabet.slice(0, i), 14 | )(new Array(64 + 1).join("1")); 15 | maxHashLength.push(maxHash.length); 16 | } 17 | 18 | console.log(maxHashLength); 19 | // [ 20 | // NaN, NaN, 64, 41, 32, 28, 25, 23, 22, 21, 20, 19, 21 | // 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 22 | // 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 23 | // 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 24 | // 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 25 | // 11, 11, 11, 11, 11 26 | // ] 27 | 28 | // refactor the above to not use any-base and still have the same result 29 | 30 | const maxHashLength2 = []; 31 | 32 | for (let i = 2; i < 65; i++) { 33 | maxHashLength2.push(Math.ceil(Math.log(i) / Math.log(2))); 34 | } 35 | 36 | console.log(maxHashLength2); 37 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json" 3 | } 4 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turbo.build/schema.json", 3 | "tasks": { 4 | "build": { 5 | "outputs": ["dist/**"], 6 | "dependsOn": ["^build"] 7 | }, 8 | "build:browser": { 9 | "outputs": ["browser.js"], 10 | "dependsOn": ["^build", "^build:browser"] 11 | }, 12 | "lint": { 13 | "dependsOn": ["^lint"] 14 | }, 15 | "test": { 16 | "dependsOn": ["^build", "^test"] 17 | }, 18 | "test:browser": { 19 | "dependsOn": ["^build", "^test:browser"] 20 | }, 21 | "dev": { 22 | "cache": false, 23 | "persistent": true 24 | }, 25 | "clean": { 26 | "cache": false 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /turbo/generators/config.ts: -------------------------------------------------------------------------------- 1 | import type { PlopTypes } from "@turbo/gen"; 2 | import * as path from "path"; 3 | 4 | // Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation 5 | 6 | export default function generator(plop: PlopTypes.NodePlopAPI): void { 7 | plop.setGenerator("package", { 8 | description: "Create a new package", 9 | prompts: [ 10 | { 11 | type: "input", 12 | name: "name", 13 | message: "What is the name of the package?", 14 | }, 15 | ], 16 | actions: [ 17 | { 18 | type: "addMany", 19 | templateFiles: "templates/package/**/*", 20 | base: "templates/package", 21 | destination: path.join(__dirname, "../../packages/{{kebabCase name}}"), 22 | }, 23 | ], 24 | }); 25 | plop.setGenerator("plugin", { 26 | description: "Create a new plugin", 27 | prompts: [ 28 | { 29 | type: "input", 30 | name: "name", 31 | message: "What is the name of the plugin?", 32 | }, 33 | ], 34 | actions: [ 35 | { 36 | type: "addMany", 37 | templateFiles: "templates/package/**/*", 38 | base: "templates/package", 39 | destination: path.join(__dirname, "../../plugins/{{kebabCase name}}"), 40 | }, 41 | ], 42 | }); 43 | } 44 | -------------------------------------------------------------------------------- /turbo/generators/templates/package/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import shared from "@jimp/config-eslint/base.js"; 2 | export default [...shared]; -------------------------------------------------------------------------------- /turbo/generators/templates/package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jimp/{{ kebabCase name }}", 3 | "version": "1.0.1", 4 | "repository": "jimp-dev/jimp", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "lint": "eslint .", 10 | "test": "vitest", 11 | "build": "tshy", 12 | "dev": "tshy --watch", 13 | "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" 14 | }, 15 | "author": "Andrew Lisowski ", 16 | "license": "MIT", 17 | "devDependencies": { 18 | "@jimp/config-eslint": "workspace:*", 19 | "@jimp/config-typescript": "workspace:*", 20 | "eslint": "^9.9.1", 21 | "tshy": "^3.0.2", 22 | "typescript": "^5.5.4", 23 | "vitest": "^2.0.5" 24 | }, 25 | "tshy": { 26 | "exclude": [ 27 | "**/*.test.ts" 28 | ], 29 | "exports": { 30 | "./package.json": "./package.json", 31 | ".": "./src/index.ts" 32 | } 33 | }, 34 | "exports": { 35 | "./package.json": "./package.json", 36 | ".": { 37 | "import": { 38 | "types": "./dist/esm/index.d.ts", 39 | "default": "./dist/esm/index.js" 40 | }, 41 | "require": { 42 | "types": "./dist/commonjs/index.d.ts", 43 | "default": "./dist/commonjs/index.js" 44 | } 45 | } 46 | }, 47 | "main": "./dist/commonjs/index.js", 48 | "types": "./dist/commonjs/index.d.ts", 49 | "type": "module", 50 | "publishConfig": { 51 | "access": "public" 52 | }, 53 | "sideEffects": false 54 | } 55 | -------------------------------------------------------------------------------- /turbo/generators/templates/package/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from "vitest"; 2 | 3 | test("adds 1 + 2 to equal 3", () => { 4 | expect(1 + 2).toBe(3); 5 | }); 6 | -------------------------------------------------------------------------------- /turbo/generators/templates/package/src/index.ts: -------------------------------------------------------------------------------- 1 | export const foo = "bar"; 2 | -------------------------------------------------------------------------------- /turbo/generators/templates/package/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jimp/config-typescript/base.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | } 6 | } 7 | --------------------------------------------------------------------------------