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...

When an object is ____, the remaining components are automatically grouped.

A. united B. divided C. compounded D. masked

Computer Science & Information Technology

Create a PL/SQL block to declare a cursor to select last name, first name, salary, and hire date from the EMPLOYEE table. Retrieve each row from the cursor and print the employee’s information if the employee’s salary is greater than $50,000 and the hire date is before 31-DEC-1997 (explicit cursor problem).

What will be an ideal response?

Computer Science & Information Technology

A query asks a table a "question."

Indicate whether the statement is true or false

Computer Science & Information Technology

In a database, a(n) __________ contains the smallest unit of meaningful information.

A. record B. field C. table D. model

Computer Science & Information Technology