Calling Javascript within Cache Object Script

Primary tabs

Has anyone called any outside Javascript code from inside their class files? I asked a long time ago if there was a way to manipulate an image within Cache Object Script, and since Cache doesn't have any image libraries its not really possible. However I have found Javascript to resize an image and wonder how hard it would be to mesh the two together.

Can anyone share any examples?



  • + 2
  • 1
  • 356
  • 6
  • 3


Hi Scott,

I assume you discovered a useful Node.js module for image manipulation in the NPM registry.

As Bernd Mueller describes in an article about callouts, I think the most efficient way is to host your Node.js module in an Node.js/Express server endpoint and make a REST call from within ObjectScript to do this. As Bernd describes, you can do this quite easily using this technique because REST calls are much more efficient than starting external (Node.js) process instances with $ZF() for each callout.

However, there's also a much more powerful variant of Node.js/Express server where you have access in JavaScript to your Caché/IRIS data too using the latest QEWD-Up server. To just manipulate an image externally this will probably look as an overkill, but for other external JavaScript modules where you need to have access to your data too, this multiprocess Node.js/Express server is a perfect fit for applications needing external functionality.

I'm using this for my applications too to use external JavaScript modules, giving you access to pretty much everything you can imagine and the NPM registry has an out-of-the-box module available for.



I haven't really dove into Node,js, but I will look into it.



Hi Scott,

I don't have an example, just an idea.

The best engine for javaScript is node.js.

You may execute your JS with node.js on command line (over $ZF or a CommandPipe) and collect the result yourself or
by Using Node.js with Caché. with direct object access.

I've seen something here

Might be a  quick hack.

I used imagemagick to do something similar and called it via $zf(-100).

FYI, the ImageMagick library can be natively integrated as a Node.js/Express (REST) endpoint using the magick-cli module in the same way as suggested in my previous answer for highest performance.

While spawning a process on Windows can be (and usually is) costly, linux offers better performance in that regard.

Additionally ImageMagick offers two C APIs: High-level and Low-Level they could be used to write a callout library, which would likely offer the best performance.


It seems Node .js is not going to be a viable option. My systems folks said it was compliled with a different GCC than what we have loaded on our AIX Server. If we were to load Node.js it would mess up the rest of the scripting (PERL, Shell) we do on the server.

Javascript was just one idea, I bet there are many other types of code that can be used to adjust an image resolution. Is there anything that can be called from Atelier without having to install a bunch of software on the server?