def showParameters (param1, param2): print "Param1 is: ", param1 print "Param2 is: ", param2 product = param1 * param2 print "The product is: ", product def getPicture(): file = pickAFile (); pict = makePicture(file); openPictureTool (pict) def cropImage(): #Allow the user to pick up an image file file = pickAFile() #print the file name user chose print file #now convert the image in JES format pic = makePicture(file) orig_width = getWidth (pic) orig_height = getHeight (pic) # decide the size of new image newWidth = 100 newHeight = 150 #now create a new image in JES format new_pic = makeEmptyPicture(newWidth, newHeight) # now decide starting with which part of image # we should crop the image start_x = 50 start_y = 100 # so we will crop the image starting from pixel # at row 100 column 50 and size of the image would be # 100 columns and 150 rows. for x in range(1, newWidth+1): for y in range(1, newHeight+1): # make sure y + start_y is less than origHeight if (y+start_y > orig_height): print "Error in y value" print "Current y+stary_y value is: ", y+start_y print "Original Height is: ", orig_height return # get pixel from original image orig_pixel = getPixel(pic, x+start_x, y+start_y); # get pixel from new image new_pixel = getPixel(new_pic, x, y); # get the color from original pixel c = getColor(orig_pixel) # set the color of new pixel to c setColor(new_pixel, c) # Now display the new image show(new_pic) # save the new image writePictureTo(new_pic, pickAFile()) def duplicateHorz(): #Allow the user to pick up an image file file = pickAFile() #now convert the image in JES format pic = makePicture(file) orig_width = getWidth (pic) orig_height = getHeight (pic) new_pict = makeEmptyPicture (orig_width*2, orig_height) for x in range (1, orig_width): for y in range (1, orig_height): opix = getPixel(pic, x,y) npix1 = getPixel (new_pict, x, y) npix2 = getPixel (new_pict, x+orig_width, y) c = getColor (opix) setColor(npix1, c) setColor(npix2, c) openPictureTool(new_pict)