Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] change picture size

I've got a scenario like this:
First scan a list of files specifically all pictures(files with .jpg or jpeg) inside one folder;
then get the size of of the picture;
if the size is greater than a certain size make it smaller; if it's already smaller than that size just continue the process;
I'd like to ask if there's a way to re-size the picture. How to design this process? Could anyone give me some idea?
Thanks!
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I finally find the solution (took a long time, ImageMagick is quite strange). It seems that in order to use ImageMagick you have to use the .exe and not use it like a .bat file. So the solution:
In your home directory: "C:\\Program Files\\ImageMagick-6.7.3-Q16"
in your tsystem, copy EXACTLY this:
"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"))
The copy of your images will be generated in the same folder of the previous images, if you want to generate them in an other folder, replace ((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")) by an other directory path
The copy fo your images will have the prefix exact, of course it's up to you to change it.
Please tell me if you have achieved it. I've made the job, it works fine.

PS: don't forget that you have to put "\\" instead of "\" when you directly write a path

View solution in original post

24 Replies
Anonymous
Not applicable
Author

Hi
I see there is a component called JavaPictureResize on Talend exchange shared by kchalane, it could be used to re-size the pictures, I did not test this component yet, hope that it is the suitable component you are looking for.
The job design looks like:
tFileList--iterate---tFileProperties---main--tJavaRow--runIf_1---JavaPictureResize
--runIf_2---continue the process
on tJavaRow:
if(input_row.size>a certain size){
globalMap.put("isgreater",true);
}else{
globalMap.put("isgreater",false);
}
set the condition of runif_1 as:
(Boolean)globalMap.get("isgreater")
set the condition of runIf_2 as:
!(Boolean)globalMap.get("isgreater")

Best regards
Shong
Anonymous
Not applicable
Author

Really appreciate your quick response. I download and installed that component.
Unfortunately, it's not allowed to connect tJavaRow to tJavapicturesize component using Runif, only row(main).
Then I tried to wrap that component into another subjob (using tRunJob). But tJavapicturesize needs input links. Is there another way to work it out?
Also that customized component is developed on tJavaRow. It seems that most code are still customized, including the parameter for the pics dimension. I really have trouble using it. I'm not good at coding thing. Any suggestion about this component?
Thanks!
Anonymous
Not applicable
Author

Hi
If the component need input links, you can use a tFixedFlowInput component to generate a row with fixed value. For example:
tFileList--iterate---tFileProperties---main--tJavaRow--runIf_1--tFixedFlowInput--main-->JavaPictureResize
--runIf_2---continue the process
I did not test this component yet, I only give you the hints and the job design, so I hope you will success in using it and share the experience with us or you know other way to re-size the picture. 0683p000009MA9p.png
Best regards
Shong
Anonymous
Not applicable
Author

Hi,
There is also ImageMagick that you can use with commandline, maybe it can help you.
Anonymous
Not applicable
Author

Hi,
There is also ImageMagick that you can use with commandline, maybe it can help you.

Good, if ImageMagick can be used with commandline way, we can use tSystem component to call ImageMagick command in Talend job.
elvalin1559, please try ImageMagick?
Best regards
Shong
Anonymous
Not applicable
Author

I'll give it a try. Thanks!
Anonymous
Not applicable
Author

Yes you have to install it, just go on the website and depending on your OS choose the right installer. Then for your job:

tFileList------tSystem
of cours you put the right directory inyour tFileList, and then for you tSystem:
"cd the_path_where_you_have_installed_imagemagick(for me C:\ImageMagick-6.7.3-Q16)" //carefull with "\", depending on the OS where the job is running
"convert "+((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 should create the converted images with the prefix "exact" in your folder. Let me now if it works. ps:I didn't check the convert method of imagmagick, i've used yours
Anonymous
Not applicable
Author

Thank you so much for your quick reply. I was just preparing to repost with my job design and ask some more question. But you've already replied so I just got that installed and tried your post.
Do I have to put something between the two command?
"cd C:\Program Files\ImageMagick-6.7.3-Q16"
"convert "+((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"))
when I was using it, got this error message
Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
then I put \n between them but still not correct. What might be the problem?
When I tried the "cd C:\Program Files\ImageMagick-6.7.3-Q16" in the cmd, it was working. I think it might be the two commands issue.
Thanks!
Anonymous
Not applicable
Author

Hi
Do I have to put something between the two command?

Check the option 'Use home directory' and browse the directory C:\Program Files\ImageMagick-6.7.3-Q16.
Best regards
Shong