Crop image - Error "Invalid values"

Discuss RoboTask here
Post Reply
juanlu
Posts: 49
Joined: Wed Jul 31, 2019 12:33 am

Crop image - Error "Invalid values"

Post by juanlu »

Hi,

When I try to use the Crop image action, I always get an error "Invalid values". I have tried the following values for Left, Top, Right, Bottom:
  • 0, 0, 0, 0
  • 1, 0 , 0, 0
  • -1, 0 , 0, 0
  • {var1}, {var2} , {var3}, {var4}
I have tried with the above values with both pixels and percentage. Always the same error.

The image is a png file. The file exists and is read successfully by RoboTask. I can get its metadata correctly. I can use the Save image action to save the same image to a different file correctly. Everything works except cropping.

Any ideas?

Kind regards, Juanlu.
juanlu
Posts: 49
Joined: Wed Jul 31, 2019 12:33 am

Re: Crop image - Error "Invalid values"

Post by juanlu »

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|637835070
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task29"
Hide=INTEGER|0
ID=INTEGER|-20513676
LocalVariables=STRING|"c_Crop_Pixels_Bottom=0,c_Crop_Pixels_Left=0,c_Crop_Pixels_Right=0,c_Crop_Pixels_Top=0,c_Folder_Name_Output=cropped_by_RT,c_Full_Folder_Name_Input=D:\temp\test,v_File_Name,v_Image_Width"
LogOnAsUser=INTEGER|1
Name=STRING|"Crop all images in folder"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action16=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action1\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{FolderExists({c_Full_Folder_Name_Input})}"

[Actions\Action10]
ActionID=STRING|"A_GRAPHICS_CROP_IMAGE"
Enabled=INTEGER|0
Name=STRING|"Crop image ({c_Crop_Pixels_Left}px, {c_Crop_Pixels_Top}px) - ({c_Crop_Pixels_Right}px, {c_Crop_Pixels_Bottom}px)"
Params=FOLDER

[Actions\Action10\Params]
b=STRING|"{c_Crop_Pixels_Bottom}"
l=STRING|"{c_Crop_Pixels_Left}"
r=STRING|"{c_Crop_Pixels_Right}"
t=STRING|"{c_Crop_Pixels_Top}"
ub=STRING|"0"
ul=STRING|"0"
ur=STRING|"0"
ut=STRING|"0"

[Actions\Action11]
ActionID=STRING|"A_GRAPHICS_CROP_IMAGE"
Enabled=INTEGER|0
Name=STRING|"Crop image (0px, 0px) - (0px, 0px)"
Params=FOLDER

[Actions\Action11\Params]
b=STRING|"0"
l=STRING|"0"
r=STRING|"0"
t=STRING|"0"
ub=STRING|"0"
ul=STRING|"0"
ur=STRING|"0"
ut=STRING|"0"

[Actions\Action12]
ActionID=STRING|"A_GRAPHICS_CROP_IMAGE"
Enabled=INTEGER|0
Name=STRING|"Crop image (0%, 0%) - (0%, 0%)"
Params=FOLDER

[Actions\Action12\Params]
b=STRING|"0"
l=STRING|"0"
r=STRING|"0"
t=STRING|"0"
ub=STRING|"1"
ul=STRING|"1"
ur=STRING|"1"
ut=STRING|"1"

[Actions\Action13]
ActionID=STRING|"A_GRAPHICS_CROP_IMAGE"
Enabled=INTEGER|0
Name=STRING|"Crop image (1px, 0px) - (0px, 0px)"
Params=FOLDER

[Actions\Action13\Params]
b=STRING|"0"
l=STRING|"1"
r=STRING|"0"
t=STRING|"0"
ub=STRING|"0"
ul=STRING|"0"
ur=STRING|"0"
ut=STRING|"0"

[Actions\Action14]
ActionID=STRING|"A_GRAPHICS_CROP_IMAGE"
Enabled=INTEGER|0
Name=STRING|"Crop image (-1px, 0px) - (0px, 0px)"
Params=FOLDER

[Actions\Action14\Params]
b=STRING|"0"
l=STRING|"-1"
r=STRING|"0"
t=STRING|"0"
ub=STRING|"0"
ul=STRING|"0"
ur=STRING|"0"
ut=STRING|"0"

[Actions\Action15]
ActionID=STRING|"A_GRAPHICS_SAVE_IMAGE"
Enabled=INTEGER|-1
Name=STRING|"Save image to '{c_Full_Folder_Name_Input}\{c_Folder_Name_Output}\{v_File_Name}'"
Params=FOLDER

[Actions\Action15\Params]
dest=STRING|"0"
format=STRING|"0"
if_exists=STRING|"0"
image_file=STRING|"{c_Full_Folder_Name_Input}\{c_Folder_Name_Output}\{v_File_Name}"
save_meta=STRING|"0"

[Actions\Action16]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action2]
ActionID=STRING|"A_FOLDER_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create Folder ({c_Full_Folder_Name_Input}\{c_Folder_Name_Output})"
Params=FOLDER

[Actions\Action2\Params]
newfolder=STRING|"{c_Full_Folder_Name_Input}\{c_Folder_Name_Output}"

[Actions\Action3]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action4]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action4\Params]
_rt_variables_produced=STRING|"v_File_Name"
createmode=STRING|"1"
date1=STRING|"20231116"
date2=STRING|"20231116"
destvar=STRING|"v_File_Name"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{c_Full_Folder_Name_Input}\*.png"
file1=STRING|"{c_Full_Folder_Name_Input}\*.jpg"
file2=STRING|"{c_Full_Folder_Name_Input}\*.jpeg"
file3=STRING|"{c_Full_Folder_Name_Input}\*.bmp"
filecount=STRING|"4"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"1"

[Actions\Action5]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message - v_File_Name"
Params=FOLDER

[Actions\Action5\Params]
message=STRING|"v_File_Name: {v_File_Name}"
type=STRING|"3"

[Actions\Action6]
ActionID=STRING|"A_GRAPHICS_OPEN_IMAGE"
Enabled=INTEGER|-1
Name=STRING|"Open image from '{c_Full_Folder_Name_Input}\{v_File_Name}'"
Params=FOLDER

[Actions\Action6\Params]
image_file=STRING|"{c_Full_Folder_Name_Input}\{v_File_Name}"
source=STRING|"0"

[Actions\Action7]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message - c_Full_Folder_Name_Input\v_File_Name"
Params=FOLDER

[Actions\Action7\Params]
message=STRING|"c_Full_Folder_Name_Input\v_File_Name: {c_Full_Folder_Name_Input}\{v_File_Name}"
type=STRING|"3"

[Actions\Action8]
ActionID=STRING|"A_GETMETADATA"
Enabled=INTEGER|-1
Name=STRING|"Get File Metadata from file {c_Full_Folder_Name_Input}\{v_File_Name}"
Params=FOLDER

[Actions\Action8\Params]
_rt_variables_produced=STRING|"v_Image_Width"
filename=STRING|"{c_Full_Folder_Name_Input}\{v_File_Name}"
prop00000000=STRING|"ancho"
propcount=STRING|"1"
var00000000=STRING|"v_Image_Width"

[Actions\Action9]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message - v_Image_Width"
Params=FOLDER

[Actions\Action9\Params]
message=STRING|"v_Image_Width: {v_Image_Width}"
type=STRING|"3"

Oleg
Site Admin
Posts: 3135
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Crop image - Error "Invalid values"

Post by Oleg »

Thank you for your report.
Thanks to your message, we discovered a small bug in the action.
The problem was that the Right and Bottom parameters could not be equals to 0.

We have already fixed this bug and released update. Just diwnload and install fresh copy here (version 9.7.2): https://robotask.com/download/
Test your task and tell about results.
Oleg Yershov
juanlu
Posts: 49
Joined: Wed Jul 31, 2019 12:33 am

Re: Crop image - Error "Invalid values"

Post by juanlu »

Hi Oleg,

Thanks for your quick response. Now it works as expected.

Kind regards, Juanlu.
Post Reply