Converting images using IRIS and image magick
Hi all
I've been looking into how to convert some images with IRIS and saw some recommendations on the forums around using image magick.
However I can't seem to get this working using ZF100 and on windows server and I'm wondering if I'm missing something really obvious as I've not used IRIS to call third party applications before.
If I run via a Windows CLI on the server, it works fine, e.g:
magick "D:\1221701739_20190716134351965_1_0.jpg" -resize 640x480 "D:\1221701739_20190716134351965_1_TEST.jpg
But I keep getting NOTOPEN when I attempt this in IRIS. I'm admin on my dev box so I think my permissions should be ok.
set sc = $ZF(-100,"/STDIN="""_imageFile_""" /STDOUT="""_tempFile_"""","magick fd:0 -resize 640x480 fd:1")
I've tried all sort of variations and logged the queries to /LOGCMD but I can't see if there is issue with the syntax
Also I think fd:0 and fd:1 are image magicks on internal flags for using STDIN / STDOUT but I've tried with the paths also.
Does any one have any examples or provide any tips how to use IRIS in this way?
Thanks
Dan
With $zf(-100) the command and its individual flags are separate arguments to the function rather than being concatenated in one string - I'd recommend trying something more like:
set sc = $ZF(-100,"/STDIN="""_imageFile_""" /STDOUT="""_tempFile_"""","magick","fd:0","-resize","640x480","fd:1")
For more details see https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
@Daniel Bertozzi , following up - I downloaded ImageMagick and the following works just fine for me (though I'm a little surprised at how slow it is):
I think the likely issue is that ImageMagick isn't on your PATH. You'll need to restart your instance for it to pick up PATH changes, so this might be the root cause if you just installed ImageMagick. Could also be interesting to run with the /SHELL flag and see if that works.
Hopefully this helps!
So it turns out my original code and your suggested version worked after all, just needed a server reboot for the PATH to take affect! I just need to sort out user permissions around the account that can use $ZF(-100) and I think I'm all good!
Anyway, I thought i'd just write up my a way of doing this in case it's helpful to anyone.
Below is a REST class that takes a list of files in array and it will convert them to Basic64 using a temp path. Example payload in the code, there's few parameters you can mess around with.
In my actual code I get paths from a SOAP interfaces and need to convert the files back to website. Therefore I am attempting to do this at the last point so it doesn't produce audits/messages. I also don't want exceptions to ever go back to the client so I will always force 1x1 image to rendered but I've added the errors back into this example.
I am using read queue to be able to monitor the output from Image like this :
Thanks very much for replying with some suggestions. It's really helpful.
@Timothy Leavitt
Thanks for the advice. I did try separate arguments in a previous version of my code, so it's nice to see I was on the right track originally so I will go back that way. With the $ZF(-100) approach I am getting 0k output file which suggest the STDOUT is being creating something (if somewhat unusable), so it could be something on the Windows side that is throwing the NOTOPEN.
@Danny Wijnschenk
I've not thought of using OPEN. It's interesting option. I was exploring this briefly just now. What would you usually expect to see in the output normally. I've just been getting a 2.
It might be helpful to see the value of $zu(56,2) after the error occurs (if you continue to get <NOTOPEN>) - of course you probably don't really need to use STDIN/STDOUT and it might be cleaner to not.
Hi Daniel, did you do a zwrite output ? It is an array, so if output=2 there should be more data in it.
(usually output is empty when the command was executed successfully)
I like using using OPEN because any shell output message is captured and can be logged.
e.g.
Ok I got your method working now also. I can see the benefit of having the shell logs captured. It's great to have two options! Thanks.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue