DEV Community


Posted on

Image processing with Jimp. Optional methods parameters.

Hi guys.

I'm working on some kind of cloud image hosting and processing. I do use Jimp, which is great and works like a charm.

Jimp's giving a lot of cool image processing methods, such as resizing, scaling and so on. You can chain methods to apply multiple effects, f.ex.:'image/path')
 .then(image => {

What do I want to achieve

I want to process images in a fly. For example, I do have an URL:


These params can be f.ex. width, height, scale, rotate etc.

For now I can manipulate image by giving one specific parameter f.ex.


and it's works - it's scaling image.

But I want to have opportunity to use bunch of options in one request f.ex.:

and I do not know how make it work. For now - Jimp offers more than 30 methods what gives us bunch of combinations so simple switch-case won't work. ;)

Basing on documentation, there is no thing such as optional params, and you cannot pass nulls or undefined as a method params.

Any ideas how can i overcome this? :)

Happy Holidays everyone!

Top comments (0)