Need a way to make thumbnails from all of the images in a directory

Discussion in 'PHP' started by vetting, Jan 5, 2008.

  1. #1
    Im alright with PHP but I'm struggling a bit to get this to work. So I have a directory called images. I have a cron job that adds images to this folder. I also need a job to go through and create thumbnails of all of the images that havent not yet been created or just add it to the end of my job that adds the images. Any advise on what thumbnail script to use and how to set it up?
     
    vetting, Jan 5, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    just write a php program and add that to cron

    in php program get all the list of files one by one

    generate the thumbnail of required size

    save it in a different folder

    Thats all

    Regards

    Alex
     
    kmap, Jan 6, 2008 IP
  3. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #3
    I just waded through a 463 script list over at hotscripts. I know that I say one or more that would do this. Not sure about the cron part. Look in >php>scripts>image gallerys.

    If you want a really cool script to do this on your local windows machine, I highly reccommend pixresizer. I can locate the link for that one if Google fails you.
     
    Colbyt, Jan 6, 2008 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    
    $image_dir  = 'images/';
    $thumb_dir = 'images/thumbs/';
    
    $image_list = glob("$image_dir/*")
    
    foreach($image_list as $image){
    	$name = basename($image);
    	if(!is_file($thumb_dir.$name)){
    		makeThumb($image_dir,$thumb_dir,$name);
    	}
    }
    
    PHP:
    Use any function for the thumbnail for makeThumb.

    Peace,
     
    Barti1987, Jan 6, 2008 IP
  5. vetting

    vetting Peon

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ended up figuring out how to immediately take the single image that was saved and then create a thumbnail of it - this then saves it back over the original image so I dont have to store the big one. Every time the script runs, it checks for that image and if it exists it goes onto the next one. Now I just need to find a different thumbnail script that I like a little more than the one I currently have. I'll take a look at the ones you guys posted. Thanks for your help.
     
    vetting, Jan 6, 2008 IP