1.1.2 Screen.capture(region, 'name') not working --- not valid in Python script

Asked by Edson Henrique Arantes on 2018-07-11

I want to save a region as a png file to process it in another app, so, no temporary save
my code is as follows:

calc = find("calculator.png")

rows = 10
cols = 4
calc.setRaster(rows, cols)
result = calc.getRow(2) # result is a new region

path = Screen.capture(result,'result.png') # the .png part can be omitted, path should have the absolute path to the image named result.png

getting the error:
"TypeError: capture(): self arg can't be coerced to org.sikuli.script.Screen "

read the documentation but I can't understand what's wrong

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2018-07-17
Last query:
2018-07-17
Last reply:
2018-07-17
Best RaiMan (raimund-hocke) said : #1

1--- get the temporary image file
tempImage = capture(result)

2--- define the new location and image file name
imagePath = "some/absolute/path"
newImage = os.path.join(imagePath, "newImage.png")

3--- move the image file
import shutil
shutil.move(tempImage, newImage)

I should use capture instead of Screen.capture(), thank you RaiMan !