GetImage
--------

GetImage derived from a request from agent23 on the coding snacks forum of donationcoder.com.

Original request:

     REQ - image search file maker 
 on: August 01, 2009, 09:17:26 AM  Quote  

--------------------------------------------------------------------------------
i would like a program that grabs the first result of a google images search and renames the flle based on the search terms. the search terms come from a list. this is a long list and each line, or list item, is each search string and needs to be the name of the file grabbed. this list is a .txt file 
the images are to be saved in a folder i choose/create. the files should be .jpg if they are not already. if there are no results then no file is named.

example: 1) program reads 'picture of a red ball' from the .txt file 2) program googles for 'picture of a red ball' in google images 3) program saves
 the first result as 'picture of a red ball.jpg'

more e.g.
list - 
some guy on boat
nov090147
happy death comics #110
abcxyz
123456

resulting file names after grab - 
some guy on boat.jpg
nov090147.jpg
happy death comics #110.jpg
abcxyz.jpg
123456.jpg 

---------------------------------------------------------------------------------

The resulting program is:
GetImage.exe

This has been written using FPC (Free pascal Compiler)



Instructions:

- No installation is required, this is a 'stand alone' exectable file. If requested, I can create a proper installation package.
- Upon execution, a small window with two buttons is shown, and a white space for the word or phrase list
- You can copy/cut/paste into the text area, load from a textfile or freely type in this area your list of words or phrases
- Once populated, click the 'Go!' button
- Now select the folder in which you want to save your jpg images in and click OK
- The text area and two buttons will disappear
- The images will now be searched for using google images, as each image is found, it is dsplayed in the window and then saved in the selected directory using the word or phrase as the file name i.e. Apples is saved as Apples.jpg in the selected directory
- A progress bar is shown at the bottom of the screen
- If no image is found or there is an error writing to the file then no file will be written for that word or phrase
- Once all words have been searched, a finish message appears, and the buttons and text areas re-appear
- If you want to download more than one of a particular image, lets say you want 2 pictures of a gorilla, 3 of a monkey 1 of an ape and 6 of a chimp.  Simply add a '/' at the end of the word or phrase followed by the number of images you want for that word.  i.e.
gorilla /2
monkey /3
ape
chimp /6
The 'multiple' files will then be named 'gorilla.1.jpg, gorilla.2.jpg' etc
- Done



Any ideas for enhancements (there are loads) or bugs let me know, and I will do my best, if I have the time to sort them out

Email me at: awopbamboo@gmail.com


J.



BUG List and History
--------------------
05/SEP/2009 : Not all images seem to download.
Reason: Problems with getting url of the images. Also, seems to be something wrong with encoding and converting to jog's on a very small number of images found. Rather than fix encoding (which would take ages), I have chaged it so it downloads the NEXT image found.
Status: Fixed  05/SEP/2009

06/SEP/2009 : Very often it doesnt get the first image. When I run a search manually I find a different, and correct, image, even after multiple tries. The file its finding is not the first result. 
This may relate to another problem. When I enter a list of similar items it grabs the same image for all of them. Example, I search for Robin #1 and Robin #2 and Robin #{3, 4,  n} it grabs the same picture for all of them. Yet manually I get a different picture for each. (in this example they are all pics of the bird which is not near the first result) I realize this may be part of the encoding issue. 
Reason: This was indeed a simple encoding problem that I have now fixed
Status: Fixed  06/SEP/2009

06/SEP/2009 : Also, some of the items may not be acceptable as file names, using characters that cannot be used in file names. I suppose well just have to skip these for now.
Reason: Not doing anything with the non accecpatble characters, which are <>:"/\|?*  Has now been changed so these characters are converted to a 'SPACE'. Unless anyone can think of a better suggestion?
Status: Fixed  06/SEP/2009

09/SEP/2009 : Added ability to download more than a oen image for each word or phrase




