I see that LoadImage does not load a valid image from an FTP path. I am guessing that this is working as designed, perhaps performance related? However double clicking to open the image with the Opus viewer works perfectly and without apparent delay. I wrote a simple detached dialog script to test this. Results as shown below for the same image, firstly from a normal local folder and then from an FTP connection to a folder on a local Synology NAS.
I will look into creating a blob object as in intermediate step and loading from that.
Having done that, my test code fails to load an FTP image via a blob object which appears to have been successfully created from a small test jpg. Code and test jpg attached.
LoadImage.dcf (6.8 KB)
9_abanchor.zip (2.5 KB)
Log data is as expected for both local and ftp.
process_load | is_image = true | C:\test\9_abanchor.jpg | size = 2719
process_load_from_ftp | ftp://SITE=SynologyNAS?:OPUS:ADDRESS:BOOK:LOOKUP://Test/9_abanchor.jpg | size = 2719 | blob_obj.size = 2719 | file_obj.error = 0
The relevant section of code follows. I noticed that if the input file item is bigger than 32K then only the first 32K is read into the blob object by the var blob_obj = file_obj.Read(); statement. No doubt I can modify the code to deal with that but since the test image is tiny that is not a concern for the purposes of my test.
function process_load_from_ftp(item)
{
if (!item.InGroup("images")) return;
var file_obj = item.Open();
if (file_obj.error!=0) return;
var blob_obj = file_obj.Read(); // Create a Blob
log(item+" | size = "+item.size+" | blob_obj.size = "+blob_obj.size+" | file_obj.error = "+file_obj.error,"process_load_from_ftp",g_colred);
g_dlg.control("Image").label = DOpus.LoadImage(blob_obj);
}
I would download the file to a temporary copy, then load it as an image. That’s probably what double-click is doing, and it will probably be more reliable that way,