Need a small program, but not sure what programming language

Discussion in 'Programming' started by tnt7, Oct 23, 2007.

  1. #1
    I am trying to figure out what programming language or combination of languages are need to accomplish this.

    I would like to have a simple excel sheet with 2 columns - "name" and "image url".


    Name | Image Url
    widget1 | http://www.widget1img.com
    widget2 | http://www.widget2img.com

    What I would like the program to do is to loop through the rows and
    Open the "image url" and automatically save the image as a .jpg extension with the name from the same row. Then have named images saved to a local folder

    (Ex. http://www.widget1img.com --> would be opened and saved as widget1.jpg to local folder).

    Anyone know of what language is required to accomplish this?
     
    tnt7, Oct 23, 2007 IP
  2. tandac

    tandac Active Member

    Messages:
    337
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    wget and a decent shell/perl/dos script could do this
     
    tandac, Oct 23, 2007 IP
  3. rknuppel

    rknuppel Well-Known Member

    Messages:
    753
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    153
    #3
    i would use perl.
     
    rknuppel, Oct 23, 2007 IP
  4. sysadm

    sysadm Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    sysadm, Oct 24, 2007 IP
  5. gota

    gota Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can do it in PHP or Perl without using COM. If you want Perl example tell me, I just did the PHP one seeing I see people like to use that more often than Perl!

    PHP

    get the class from sourceforge

    sourceforge.net/project/downloading.php?groupname=phpexcelreader&filename=Spreadsheet_Excel_Reader.zip&use_mirror=superb-west
    Code (markup):

    Quick example using it!

    <?php
    
    // same image path
    
    $path = './images/';
    
    // excel reader class
    
    require './reader.php';
    
    // reader object
    
    $object = new Spreadsheet_Excel_Reader ();
    
    // out encoding type
    
    $object->setOutputEncoding ( 'UTF-8' );
    
    // open the excel file for reading
    
    $object->read ( './urls.xls' );
    
    // process the excel sheet
    
    foreach ( $object->sheets[0]['cells'] AS $row )
    {
    	/*
    	* i am using... (for each row being read)
    	* $row[0] = column number that holds the image name (IE: widget1)
    	* $row[1] = column number that holds the image url (IE: http://www.widget2img.com/image.jpg)
    	*/
    
    	if ( false !== ( $image = file_get_contents ( $row[1] ) ) )
    	{
    		$io = fopen ( $path . $row[0] . '.jpg', 'wb' );
    		fputs ( $io, $image );
    		fclose ( $io );
    	}
    }
    
    $object = null;
    
    exit ();
    
    ?>
    PHP:
     
    gota, Oct 25, 2007 IP