Working with Images
Before you start, find an image to work with. It will be easiest if you choose a smaller image to start with. One less than 400 x 400 pixels would be best.
Lets look at some of the commands you can use in Jython to work with images. You can type these directly into the Command (bottom) Window.
![]() |
|
In the command window try out: print pickAFile()
It will output the path and filename of the file you select.
![]() |
|
So we have now made the file into a picture, but we can't see it yet. To show it we use the command show()
![]() |
|
Picking and Showing your Picture in one Command
Rather than typing all those commands each time we can create a picture showing recipe (function)
You can assign the file picked to a variable to store it for later use. For example
myfile=pickAFile()
print myfile
will print the path and name of the selected file.
In the top (program) window, type the following (take care to indent the lines as shown below)
def pickAndShow():
|
Once you’ve typed in your recipe you can load it. Click the Load button. You will be prompted to Save it first.
Now in the bottom (command) window, type pickAndShow()
The file you select should be shown in an image window.
![]() |
|


