@jimp/core
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -0,1 +1,23 @@ | ||
# v1.5.0 (Sat Sep 07 2024) | ||
### Release Notes | ||
#### Add support for image decoder options ([#1336](https://github.com/jimp-dev/jimp/pull/1336)) | ||
Can now have options for the underlying image codecs | ||
![CleanShot 2024-09-07 at 15 26 41](https://github.com/user-attachments/assets/26fa1a48-f463-455c-89f9-9c99f9fcb3d1) | ||
--- | ||
#### 🚀 Enhancement | ||
- Add support for image decoder options [#1336](https://github.com/jimp-dev/jimp/pull/1336) ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### Authors: 1 | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
--- | ||
# v1.4.0 (Sat Sep 07 2024) | ||
@@ -2,0 +24,0 @@ |
@@ -117,3 +117,3 @@ "use strict"; | ||
*/ | ||
static async read(url) { | ||
static async read(url, options) { | ||
if (Buffer.isBuffer(url) || url instanceof ArrayBuffer) { | ||
@@ -137,3 +137,3 @@ return this.fromBuffer(url); | ||
const buffer = bufferFromArrayBuffer(data); | ||
return this.fromBuffer(buffer); | ||
return this.fromBuffer(buffer, options); | ||
} | ||
@@ -197,3 +197,3 @@ /** | ||
*/ | ||
static async fromBuffer(buffer) { | ||
static async fromBuffer(buffer, options) { | ||
const actualBuffer = buffer instanceof ArrayBuffer ? bufferFromArrayBuffer(buffer) : buffer; | ||
@@ -208,3 +208,3 @@ const mime = await core_js_1.default.fromBuffer(actualBuffer); | ||
} | ||
const image = new CustomJimp(await format.decode(actualBuffer)); | ||
const image = new CustomJimp(await format.decode(actualBuffer, options?.[format.mime])); | ||
image.mime = mime.mime; | ||
@@ -211,0 +211,0 @@ (0, image_bitmap_js_1.attemptExifRotate)(image, actualBuffer); |
@@ -94,3 +94,3 @@ import { Edge } from "@jimp/types"; | ||
*/ | ||
static async read(url) { | ||
static async read(url, options) { | ||
if (Buffer.isBuffer(url) || url instanceof ArrayBuffer) { | ||
@@ -114,3 +114,3 @@ return this.fromBuffer(url); | ||
const buffer = bufferFromArrayBuffer(data); | ||
return this.fromBuffer(buffer); | ||
return this.fromBuffer(buffer, options); | ||
} | ||
@@ -174,3 +174,3 @@ /** | ||
*/ | ||
static async fromBuffer(buffer) { | ||
static async fromBuffer(buffer, options) { | ||
const actualBuffer = buffer instanceof ArrayBuffer ? bufferFromArrayBuffer(buffer) : buffer; | ||
@@ -185,3 +185,3 @@ const mime = await fileType.fromBuffer(actualBuffer); | ||
} | ||
const image = new CustomJimp(await format.decode(actualBuffer)); | ||
const image = new CustomJimp(await format.decode(actualBuffer, options?.[format.mime])); | ||
image.mime = mime.mime; | ||
@@ -188,0 +188,0 @@ attemptExifRotate(image, actualBuffer); |
{ | ||
"name": "@jimp/core", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"repository": "jimp-dev/jimp", | ||
@@ -18,5 +18,5 @@ "engines": { | ||
"dependencies": { | ||
"@jimp/file-ops": "1.4.0", | ||
"@jimp/types": "1.4.0", | ||
"@jimp/utils": "1.4.0", | ||
"@jimp/file-ops": "1.5.0", | ||
"@jimp/types": "1.5.0", | ||
"@jimp/utils": "1.5.0", | ||
"await-to-js": "^3.0.0", | ||
@@ -28,5 +28,5 @@ "exif-parser": "^0.1.12", | ||
"devDependencies": { | ||
"@jimp/config-eslint": "1.4.0", | ||
"@jimp/config-typescript": "1.4.0", | ||
"@jimp/test-utils": "1.4.0", | ||
"@jimp/config-eslint": "1.5.0", | ||
"@jimp/config-typescript": "1.5.0", | ||
"@jimp/test-utils": "1.5.0", | ||
"@types/file-type": "^10.9.1", | ||
@@ -71,3 +71,3 @@ "@types/mime": "^3.0.4", | ||
"module": "./dist/esm/index.js", | ||
"gitHead": "c1b91e9007f17d0702894bd9bfab8215cff764f9" | ||
"gitHead": "9b8d6106ef2498113ebcdddf8e6a4fae0b3cadff" | ||
} |
@@ -101,5 +101,10 @@ import { Bitmap, Format, JimpClass, Edge } from "@jimp/types"; | ||
type JimpFormat< | ||
M extends string = string, | ||
O extends Record<string, any> | undefined = undefined, | ||
T extends Format<M, O> = Format<M, O>, | ||
MimeType extends string = string, | ||
EncodeOptions extends Record<string, any> | undefined = undefined, | ||
DecodeOptions extends Record<string, any> | undefined = undefined, | ||
T extends Format<MimeType, EncodeOptions, DecodeOptions> = Format< | ||
MimeType, | ||
EncodeOptions, | ||
DecodeOptions | ||
>, | ||
> = () => T; | ||
@@ -109,2 +114,4 @@ | ||
T extends Format<infer M, infer O> ? Record<M, O> : never; | ||
type CreateMimeTypeToDecodeOptions<T extends Format<string, any>> = | ||
T extends Format<infer M, any, infer O> ? Record<M, O> : never; | ||
type GetOptionsForMimeType<Mime extends string, MimeTypeMap> = | ||
@@ -143,2 +150,5 @@ MimeTypeMap extends Record<Mime, infer O> ? O : never; | ||
>; | ||
type MimeTypeToDecodeOptions = CreateMimeTypeToDecodeOptions< | ||
ReturnType<Formats[number]> | ||
>; | ||
type ExtensionToMimeType = CreateExtensionToMimeType<SupportedMimeTypes>; | ||
@@ -219,3 +229,6 @@ | ||
*/ | ||
static async read(url: string | Buffer | ArrayBuffer) { | ||
static async read( | ||
url: string | Buffer | ArrayBuffer, | ||
options?: MimeTypeToDecodeOptions | ||
) { | ||
if (Buffer.isBuffer(url) || url instanceof ArrayBuffer) { | ||
@@ -246,3 +259,3 @@ return this.fromBuffer(url); | ||
const buffer = bufferFromArrayBuffer(data); | ||
return this.fromBuffer(buffer); | ||
return this.fromBuffer(buffer, options); | ||
} | ||
@@ -322,3 +335,6 @@ | ||
*/ | ||
static async fromBuffer(buffer: Buffer | ArrayBuffer) { | ||
static async fromBuffer( | ||
buffer: Buffer | ArrayBuffer, | ||
options?: MimeTypeToDecodeOptions | ||
) { | ||
const actualBuffer = | ||
@@ -340,3 +356,3 @@ buffer instanceof ArrayBuffer ? bufferFromArrayBuffer(buffer) : buffer; | ||
const image = new CustomJimp( | ||
await format.decode(actualBuffer) | ||
await format.decode(actualBuffer, options?.[format.mime]) | ||
) as InstanceType<typeof CustomJimp> & ExtraMethodMap; | ||
@@ -343,0 +359,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
374828
7578
+ Added@jimp/file-ops@1.5.0(transitive)
+ Added@jimp/types@1.5.0(transitive)
+ Added@jimp/utils@1.5.0(transitive)
- Removed@jimp/file-ops@1.4.0(transitive)
- Removed@jimp/types@1.4.0(transitive)
- Removed@jimp/utils@1.4.0(transitive)
Updated@jimp/file-ops@1.5.0
Updated@jimp/types@1.5.0
Updated@jimp/utils@1.5.0