Media Programming Introduction

JES is a programming environment for Python. It allows you to  write Python programs that perform Photoshop-like effects on pictures. Its a fun way to learn how to program and create some cool images.
 
If you don't have JES on your computer, you can download it at http://coweb.cc.gatech.edu/mediaComp-plan/94. If you're working in a USF CS lab, JES is already installed. On Linux, you can find it in Applications | Programming | JES. On Windows, look for the frog in 'All Programs'.
 
JES has two main windows.
The bottom panel is an interactive interpreter. This allows you to try a single command at a time.

Usually you'll use the top window, which is a text editor. You write the program there, then click 'Load program' to run it.

Tutorial

1. With JES you work with pictures. So the first step is to download an image from the web into your H: directory. With most browsers, you can right-click an image and choose "Save Images as" or something similar.

2. Open the JES programming environment and type in the following mini-program into the top panel editor. You need not type in the # or the comments after.

fileName= pickAFile()                                                     # this asks the end-user to choose a graphic file
pic = makePicture(fileName)                                        # this creates a picture in memory holding the pixels of the image.
show(pic)                                                                             # this renders the picture.

Enter the lines exactly as shown above, then click File | Save Program. Save in imageSample.py.

3. Run your program by clicking the "Load Program" near the middle of the JES Window. You (the end-user) will be prompted to choose a .jpg or other graphic file. Choose an image from one of your folders, and the program should render the picture. That is all this first program does.

4. Now we'll modify your program and have it change the image, just as a human might do in Photoshop. For now, let's just draw some text and a line on our picture. Add the following below the previous code in your sample.py file:
 
addLine(pic,0,0,200,200)                                             # draw a line going from coordinate (0,0) to (200,200)
addText(pic,100,100,"hey dude")                               # draw some text at coordinate (100,100)
repaint(pic)                                                                        # this will render the picture with the changes.   
 
Do you see the line on the picture? Try different numbers and text for the parameters. What happens?
 
5. Note that the manipulations take place on an in-memory (RAM)  version of the image. You can save the modified image to a file:
 
writePictureTo(pic,'/home/wolber/pics/out.jpg')

If you're using Windows, you need to put an 'r' in front of the file path. For instance:

        writePictureTo(pic,r"H:\out.jpg"
)

Add the appropriate line to the bottom of your program, rerun your program, then go into the folder you specified and see if the new file has been created and if the image inside it is the modified picture.

6. Play around with some of the Photoshop-like functions that JES provides. To view a list of the functions,  select Help ! Understanding Pictures | Picture Functions in JES. This specification describes the functions you can call.
 
Good Job! Next, we'll learn how to manipulate images pixel by pixel.

Recent site activity