Back to DFS's Workshop Page
Back to Agenda Page


Making Thumbnails Problem

This problem is part of the larger Creating a Picture Website project. The script will create thumbnails for all pictures in JPEG format, placing them in a subdirectory. It will also store information about the pictures in a file called piclist.txt. Your script should do the following.

  1. Accept a directory path; this can be typed into the URL line if you are running the script though a browser or given as an argument or hardset if you are testing the script from the Command Line; eventually, this script will be called by pickpicdir.php, which is written in Navigate Directories script.
  2. Create in that directory a subdirectory called "Thumbnails" with perms of 777; this directory will house the thumbnails which will be created (you can check whether it already exists with the is_dir() function).
  3. Open a file for writing called piclist.txt which will have the following format:
    directory/path/belowpublic_html/
    GroupNumber\tPictureNumber\tLargePicName\tThumbnailName
    
    Click here to see a filled-in file.
  4. Use explode() to facilitate assembling of the directory path to be put in piclist.txt.
  5. Use popen() to get a directory listing of the current directory.
  6. Use explode on each file name to check for a jpg suffix.
  7. If a jpg suffix is found, create an entry in piclist.txt, create a thumbnail name and call a programmer-defined function named createthumbnail() which creates and writes a thumbnail picture to the Thumbnails/ directory.

If you are doing the whole Picture Website Creation Project, have this script function through the web browser, being called by the Navigate Directories script.

Also, add the following line to the head of the page generated so that the thumbnails are displayed after a two-second delay.

<meta http-equiv="refresh" content="2 url=showthumbnails.php?curdir=$currentdir">

Notes


© 2005 DFStermole
Created 1 Dec 05
Last Modified 6 Dec 05