One Star

image resize - problem with ImageMagick in tSystem

I'm using ImageMagick in tSystem to resize a picture.
In the command,
"C:\\Program Files\\ImageMagick-6.7.3-Q16\\convert.exe "+((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")) +" -resize 64x64! "+((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY"))+"\\exact_"+((String)globalMap.get("tFileList_1_CURRENT_FILE"))+"."+((String)globalMap.get("tFileList_1_CURRENT_FILEEXTENSION"))

It was working fine but I just found one problem.
I'm using ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")) to get the file name and path. As long as there's no space in the file name, it's working well. Like C:/folder1/folder2/testa.jpg. It works.
But if the file name changed to test a.jpg like C:/folder1/folder2/test a.jpg then it failed to run.
And will get error as follows:
Magick: unable to open image `C:\folder1/folder2/test': No such file or directory @ error/blob.c/OpenBlob/2589.
Magick: no decode delegate for this image format `C:\folder1/folder2/test' @ error/constitute.c/ReadImage/532.
Magick: unable to open image `a.jpg': No such file or directory @ error/blob.c/OpenBlob/2589.
Magick: unable to open image `folder1/folder2/test': No such file or directory @ error/blob.c/OpenBlob/2589.
Magick: no decode delegate for this image format `C:\folder1/folder2/test' @ error/constitute.c/ReadImage/532.
Magick: missing an image filename `a.jpg' @ error/convert.c/ConvertImageCommand/3016.

Does it mean I couldn't have space in the file name? How can I do to make it work with space?
Could anyone help me on this please? Thanks!!!!
6 REPLIES
One Star

Re: image resize - problem with ImageMagick in tSystem

Hi
Check "Use Array Command".
Regards,
Pedro
One Star

Re: image resize - problem with ImageMagick in tSystem

What version talend do u use? I'm using 5.0.1 and I don't see the array/single command in the component? Do I have to update the component? Or Is there other way to solve it?
Thanks!
One Star

Re: image resize - problem with ImageMagick in tSystem

Hi
My TOS version is TOS_DI-r75219-V5.0.1NB.
I notice that this new feature will be added in TOS 5.1.0.
Now you can use this workaround.
new String[]{"C:\\Program Files\\ImageMagick-6.7.3-Q16\\convert.exe",((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")) }

Regards,
Pedro
One Star

Re: image resize - problem with ImageMagick in tSystem

Thanks for your reply first.
I have to put everything inside like the following or just the first two part like the one you showed me below?
new String[]{"C:\\Program Files\\ImageMagick-6.7.3-Q16\\convert.exe",((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))," -resize 64x64! ", ((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")),"\\exact_",((String)globalMap.get("tFileList_1_CURRENT_FILE")),".",((String)globalMap.get("tFileList_1_CURRENT_FILEEXTENSION"))}
I tried both but still got error message from both of them. I shouldn't have space in the filepath?
Thanks!!!
One Star

Re: image resize - problem with ImageMagick in tSystem

Hi
The reason is that you put wrong parameters in String[] array.
Each String[] array element should be a parameter.
(String)globalMap.get("tFileList_1_CURRENT_FILE")),".",((String)globalMap.get("tFileList_1_CURRENT_FILEEXTENSION"))

or
"\\exact_",((String)globalMap.get("tFileList_1_CURRENT_FILE")),".",((String)globalMap.get("tFileList_1_CURRENT_FILEEXTENSION"))

They may be one parameter. I don't know how to use this command.
Maybe the command should be like this.
new String[]{"C:\\Program Files\\ImageMagick-6.7.3-Q16\\convert.exe",
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))," -resize 64x64! ",
(String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY"))+"\\exact_"+
((String)globalMap.get("tFileList_1_CURRENT_FILE"))+"."+((String)globalMap.get("tFileList_1_CURRENT_FILEEXTENSION"))}

Hope you make it clear.
Regards,
Pedro
One Star

Re: image resize - problem with ImageMagick in tSystem

Thanks for correcting me. I think I got your point. I tried it like the one you showed.
Here's the error msg I got:
Magick: unable to open image ` -resize 64x64! ': No such file or directory @ error/blob.c/OpenBlob/2589.
Magick: no decode delegate for this image format ` -resize 64x64! ' @ error/constitute.c/ReadImage/532.

I also tried to include that ` -resize 64x64! ' with other parts. But it still failed. Really appreciate your advice!!!
Thanks!!!