Given a folder with images in it, create an index HTML page with links to each image. Write a function that takes a string which is the path to a directory. You will create a page in the folder named index.html that should be an HTML page containing a link to every JPEG file in the directory. You will also generate a thumbnail (half the size) copy of each image. Use makeEmptyPicture to create a blank picture of the right size, then scale down the original picture into the blank picture. Name the new image “half-” + the original filename (e.g., if the original filename was fred.jpg, save the half-size image as half-fred.jpg). The anchor in the link to each full-size picture should be the half-size image.

What will be an ideal response?

```
def createThumbnailSite(directory):
indexFile = open(directory+"/index.html", "wb")
for file in os.listdir(directory):
if file.endswith(".jpg"):
pic = makePicture(directory+"/"+file)
width = getWidth(pic)
height= getHeight(pic)

newPic = makeEmptyPicture(width/2, height/2)

sourceX = 0
for x in range(0, width/2):
sourceY = 0
for y in range(0, height/2):
color = getColor(getPixel(pic, sourceX, sourceY))
setColor(getPixel(newPic,x, y), color)
sourceY = sourceY+2
sourceX = sourceX+2

writePictureTo(newPic, directory+"/half-"+file)

lStart = ""
lMid = ""
lEnd = "
"
indexFile.write(lStart+lMid+lEnd)
indexFile.close()
```

Computer Science & Information Technology

You might also like to view...

Activity Monitor can help you assess CPU and memory utilization.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Define what is meant by a structured decision.

What will be an ideal response?

Computer Science & Information Technology