/ Published in: PHP
This code is not made by me : But it was used for one of my projects. This code scans for all png files in a directory and creates a 100x100 thumbnail and moves it into a specified directory.
:.INCLUDES A DATA TEXT CODE WHICH PUTS THE NAMES OF ALL FILES IN THAT DIRECTORY INTO A TEXT FILE, WHICH IS SAVED AS data.txt.:
:.INCLUDES A DATA TEXT CODE WHICH PUTS THE NAMES OF ALL FILES IN THAT DIRECTORY INTO A TEXT FILE, WHICH IS SAVED AS data.txt.:
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) { // open the directory // loop through it, looking for any/all PNG files: // parse path for the extension // continue only if this is a PNG image { //echo "Creating thumbnail for {$fname} <br />"; // load image and get image size // calculate thumbnail size $new_width = $thumbWidth; // create a new temporary image // copy and resize old image into new image // save thumbnail into a file //Data Text Save [OPTIONAL] //$myFile = "data.txt"; //$fh = fopen($myFile, 'a') or die("can't open file"); //$stringData = $fname."\n"; //fwrite($fh, $stringData); //fclose($fh); } } // close the directory } ?>