Overwrite during image capture

Asked by Collin Tobin

I'd like to enable overwriting of images when capturing them.

Sikuli is being very careful and renaming my image captures (if using the same name) by enumerating them "image" "image-1" "image-2". But most of my capturing is correcting an image, and I have to go and manually delete an image before recapturing which is very clunky. I'd rather a settings so that Sikuli will overwrite pre-existing captures.

Is there a way?

Thanks.

Question information

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

Sorry, currently no changeable default behaviour.

this trick works:
- in Prefs -> more activate "delete unused images"
- delete the icon you want to recapture
- save the script (if it is not used anywhere else in this script, the image file will be deleted)
- recapture and use the old name

If you want to use the same image in more than one place, always use
image1 = "image1.png"
find(image1)
...
click(image1)

... do not copy and paste thumbnails or image file names, so one image filename will only be used in one place and the above trick works.

version 2 will have more options for this.

Revision history for this message
Collin Tobin (coljtob) said :
#2

Thanks RaiMan. Unfortunately, in this scenario, I'm not updating my script at all.

And I'm using my own custom functions to reference images so I can use the same functions across different devices/platforms, like this:

def customWait(imageName, time, tolerance):

So despite the function/script being correct, quite often I'll have to update the image in question. I have the script pausing execution when an image isn't found. I'd like to just recapture the image while in a paused state without having to manually delete the original.

My current workflow is:

1) Execute tests
2) Pause when image is not found (find failed response set to PROMPT)
3) If I deem a recapture necessary, I have to manually find and delete the original by hand
4) Recapture the new image (making sure the correct script has focus, otherwise the image gets saved in the wrong folder)
5) Resume the test

I'd love to be able to have an "overwrite" setting in the IDE to never try to preserve an original with the "Name the Screenshot" dialog?

Thanks.

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

ok, understood.

A capture (no image file found) and recapture option at FindFailedResponse PROMPT will be available anyway in version 2 (might be in a 1.1.x revision later this year) and additionally a response type HANDLER specifying a handler, where you can do whatever you want before resuming (like with observe).

... but sorry for now: no solution for your workflow currently.

I will add an option
Settings.OverwriteImages = false (as default)

So when available in one of the next nightly builds of 1.1.0, you might try it out:
somewhere at the beginning of a script session simply say
Settings.OverwriteImages = true

and on recapture the images will be overwritten without notice (since you know, what you are doing).

You might as well post a request bug and watch when it is tagged FixCommitted/Critcal, which signals the availability in the nightly build.

Revision history for this message
Collin Tobin (coljtob) said :
#4

Thanks, I will file that. Appreciate the prompt and thorough responses.