Question
· Dec 21, 2018

Calling Javascript within Cache Object Script

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?

Thanks

Scott

Discussion (9)2
Log in or sign up to continue

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.

HTH,

Ward

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?