Using imagemagick in code blocks

Hi folks,

anyone had luck using imagemagick in Workflow code blocks?
Specifically for image resizing. I'm fetching an image from S3, and want to reduce it to a thumbnail.

After including it in the JS libraries of the workflow, it can't be referenced, required or imported. Code blocks that reference it fail with imagemagick is not defined.

Hello @hansontools!

Unfortunately I have not heard of anyone using the 'imagemagick' library in Retool :sweat_smile:

I was just trying to test it out and it looks like there are two steps to add in a custom library to workflows.

It sounds like you did the first one, adding it to the JS libraries.

The second step is adding the library to the 'Javascript configuration' page. This can be found when you click on the :gear: symbol at the left side panel at the bottom.

There are a number of similarly named libraries that list imageMagick functionality, I found that the first two options that pop up when I typed in imageMagick require a CLI tool, which I do not think we are able to add in as a dependency.

However this library called 'gm' from the screenshot I posted above claims to have "GraphicsMagick and ImageMagick for node.js" and did not immediately error for lack of CLI dependency :sweat_smile:

Let me know if it works for you, might need to test out some other libraries as well!

Thanks @Jack_T
I found another small lib that did the job - image-thumbnail

Extra JS libs don't need to be added to the JS configuration. You can just require them in the code block.

@hansontools Great to hear!

Thank you for finding that library, hopefully that info can help other users that are looking for the right library for modifying images :sunglasses:

That is also good to hear that the process is as simple as using require for the library in the code block. Makes sense as our executor should import them when it runs.

I definitely thought it also had to be added to the JS config :sweat_smile: