Capture is going to temp instead of project folder

Asked by GZ

Hi Everyone,

When using the capture(Region=(x,y,w,h)) command, the saved image is going to the temp folder of the OS instead of the .sikuli folder of the project.

I assume this is a bug as I've read that it should go to the .sikuli folder, which is what I want. I'm on the 1.1.1 release version.

**BTW, it would be amazing if we could name and choose path for these captures**
Something like capture(region, path, filename) would be awesome!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
GZ
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Capture since the beginning in 2010 is a prominent feature in SikuliX, but also the API/usage differed on the 3 levels IDE/Python/Java from beginning.

Over the time I tried to smooth the differences and add features in the sense of your request.
But I have to admit, that the docs do not really talk about ;-)

Internally a capture in all its variants creates a ScreenImage object, that in the first place holds an in-memory image representing the captured pixels. ScreenImage has methods to store the image in various places.
But due to backward compatibility reasons at the Python level the problem cannot be solved by augmenting the capture() command.
This is still valid:
http://sikulix-2014.readthedocs.io/en/latest/screen.html#Screen.capture

To get access to the intermediate ScreenImage object from the Python level, you have to say
screenImage = SCREEN.capture(<parameters as doc'ed>)

... then you have
screenImage.saveInBundle(name) # save in current bundle path using name (.png can be omitted)
screenImage.getFile(path, name) # save in given path using name (.png can be omitted)

I have not yet decided, how to finally solve the problem, but I will add least add the above as a note to the docs of capture().

In this sense thanks for the question.

Revision history for this message
GZ (g-zr) said :
#2

Great! Thanks very much RaiMan!

Revision history for this message
RaiMan (raimund-hocke) said :
#3

I find a way, to implement your requested feature.
Available now in the latest nightly 1.1.2

Revision history for this message
RaiMan (raimund-hocke) said :
#4

for a preliminary description see the bug.