Skip to content

Unable to configure decoder options #939

@myisaak

Description

@myisaak

https://github.com/oliver-moran/jimp/blob/909f06eac36ef5ba36ebb1e0853fd006c4da3560/packages/core/src/utils/image-bitmap.js#L165

This library doesn't allow for configuring some decoders that take extra parameters. The line above shows this explicitly where only one argument is given instead of at least another options object. Decoders such as the jpeg-js one offer extra configurations in the form of another configuration that can be useful for a given context (see here google/eleventy-high-performance-blog#10).

My proposal fix would be to change the constructor function to allow an decoderOptions key that map mimetypes to the respective decoder options. For example:

const decoderOptions = {
  "image/jpeg": {
    maxMemoryUsageInMB: 1024,
  }
};
Jimp.decode({ path: "filepath.jpg", decoderOptions, });
Jimp.decode("filepath.jpg", { decoderOptions }); // alternative

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions