function handleDirFiles($dir_name, $save_dir) { list($directories, $files) = File_Find::maptree($dir_name); $new_dir = $save_dir . basename($dir_name); if (!file_exists($new_dir)) { mkdir($new_dir, 0777); } foreach ($files as $image_file) { if (ereg("(.*)jpg\$", $image_file)) { $new_filename = $new_dir . "/" . basename($image_file, ".jpg") . "_resize.jpg"; echo $new_filename . "\n"; $tn_image = new Thumbnail($image_file, 340); $tn_image->save($new_filename); $Canvas =& Image_Canvas::factory(isset($_GET['canvas']) ? $_GET['canvas'] : 'jpg', array('width' => 340, 'height' => 340)); $Canvas->image(array('x' => 340, 'y' => 340, 'filename' => $new_filename, 'alignment' => array('horizontal' => 'right', 'vertical' => 'bottom'))); $Canvas->setFont(array('name' => 'Courier New', 'size' => 16, 'color' => '#FF66FF')); //#FF0033 $Canvas->addText(array('x' => 165, 'y' => 200, 'text' => 'arzen1013', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom'))); $Canvas->setFont(array('name' => 'Courier New', 'size' => 10, 'color' => '#000000')); //#FF0033 $Canvas->addText(array('x' => 165, 'y' => 320, 'text' => 'http://shop33691629.taobao.com/', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom'))); $Canvas->save(array('filename' => $new_filename)); } } }
/** * Search the specified directory tree with the specified pattern. Return * an array containing all matching files (no directories included). * * @param string $pattern the pattern to match every file with. * * @param string $directory the directory tree to search in. * * @param string $type the type of regular expression support to use, either * 'php' or 'perl'. * * @param bool $fullpath whether the regex should be matched against the * full path or only against the filename * * @param string $match can be either 'files', 'dirs' or 'both' to specify * the kind of list to return * * @return array a list of files matching the pattern parameter in the the * directory path specified by the directory parameter * * @author Sterling Hughes <*****@*****.**> * @access public * @static */ function &search($pattern, $directory, $type = 'php', $fullpath = true, $match = 'files') { $matches = array(); list($directories, $files) = File_Find::maptree($directory); switch ($match) { case 'directories': $data = $directories; break; case 'both': $data = array_merge($directories, $files); break; case 'files': default: $data = $files; } unset($files, $directories); $match_function = File_Find::_determineRegex($pattern, $type); reset($data); while (list(, $entry) = each($data)) { if ($match_function($pattern, $fullpath ? $entry : basename($entry))) { $matches[] = $entry; } } return $matches; }
/** * Search the specified directory tree with the specified pattern. Return * an array containing all matching files (no directories included). * * @param string $pattern the pattern to match every file with. * * @param string $directory the directory tree to search in. * * @param string $type the type of regular expression support to use, either * 'php', 'perl' or 'shell'. * * @param bool $fullpath whether the regex should be matched against the * full path or only against the filename * * @param string $match can be either 'files', 'dirs' or 'both' to specify * the kind of list to return * * @return array a list of files matching the pattern parameter in the the * directory path specified by the directory parameter * * @author Sterling Hughes <*****@*****.**> * @access public * @static */ function &search($pattern, $directory, $type = 'php', $fullpath = true, $match = 'files') { $matches = array(); list($directories, $files) = File_Find::maptree($directory); switch ($match) { case 'directories': $data = $directories; break; case 'both': $data = array_merge($directories, $files); break; case 'files': default: $data = $files; } unset($files, $directories); $match_function = File_Find::_determineRegex($pattern, $type); reset($data); // check if empty string given (ok for 'shell' method, but bad for others) if ($pattern || $type != 'php' && $type != 'perl') { while (list(, $entry) = each($data)) { if ($match_function($pattern, $fullpath ? $entry : basename($entry))) { $matches[] = $entry; } } } sort($matches); return $matches; }
/** * Returns list of files parsed * * Returns list of files parsed, depending of restrictive parser options. * * @param mixed $dir The directory name where to look files * @param array $options An array of parser options. See parseData() method. * * @access public * @return array list of files that should be parsed * @since version 1.8.0b2 (2008-06-03) */ function getFilelist($dir, $options) { $skipped = array(); $ignored = array(); $options = array_merge($this->options, $options); $options['file_ext'] = array_map('strtolower', $options['file_ext']); if ($dir[strlen($dir) - 1] == '/' || $dir[strlen($dir) - 1] == '\\') { $dir = substr($dir, 0, -1); } // use system directory separator rather than forward slash by default $ff = new File_Find(); $ff->dirsep = DIRECTORY_SEPARATOR; // get directory list that should be ignored from scope $ignore_dirs = array(); if (count($options['ignore_dirs']) > 0) { foreach ($options['ignore_dirs'] as $cond) { $cond = str_replace('\\', "\\\\", $cond); $dirs = $ff->search('`' . $cond . '`', $dir, 'perl', true, 'directories'); $ignore_dirs = array_merge($ignore_dirs, $dirs); } } // get file list that should be ignored from scope $ignore_files = array(); if (count($options['ignore_files']) > 0) { foreach ($options['ignore_files'] as $cond) { $cond = str_replace('\\', "\\\\", $cond); $files = $ff->search('`' . $cond . '`', $dir, 'perl', true, 'files'); $ignore_files = array_merge($ignore_files, $files); } } list($directories, $files) = $ff->maptree($dir); foreach ($files as $file) { $file_info = pathinfo($file); if ($options['recurse_dir'] == false && $file_info['dirname'] != $dir) { $skipped[] = $file; continue; } if (in_array($file_info['dirname'], $ignore_dirs)) { $ignored[] = $file; } elseif (in_array($file, $ignore_files)) { $ignored[] = $file; } else { if (isset($file_info['extension']) && in_array(strtolower($file_info['extension']), $options['file_ext'])) { continue; } $ignored[] = $file; } } $files = PHP_CompatInfo_Parser::_arrayDiff($files, array_merge($ignored, $skipped)); $this->directories = PHP_CompatInfo_Parser::_arrayDiff($directories, $ignore_dirs); $this->ignored_files = $ignored; return $files; }
* @author John.meng <*****@*****.**> * @author цот╤РШ * @author QQ:3440895 * @version CVS: $Id: ImageMagickTool.php,v 1.4 2006/10/25 14:22:38 arzen Exp $ */ set_time_limit(0); define('APF_ROOT_DIR', realpath(dirname(__FILE__) . '/../..')); require_once APF_ROOT_DIR . DIRECTORY_SEPARATOR . 'init.php'; require_once 'File/Find.php'; require_once $ClassDir . 'ImageMagickUtility.class.php'; //$source_name = 'C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Water lilies.jpg'; //$string = "testing"; //$save_name = "D:/www/tools/Water lilies.jpg"; //ImageMagickUtility::addText($source_name,$string,$save_name); //ImageMagickUtility::resize($source_name,0,120); $dir = 'D:/м╪ф╛/дою╔и╫ф╞аВ2006-8-15/'; list($directories, $files) = File_Find::maptree($dir); $x = 0; foreach ($files as $image_file) { if (eregi("(.*)jpg|gif\$", $image_file)) { $source_name = $image_file; $file_arr = pathinfo($source_name); $dir_name = $file_arr["dirname"]; $exten_name = $file_arr["extension"]; $base_name = basename($file_arr["basename"], "." . $exten_name); $save_name = $dir_name . "/resize_" . $base_name . "." . $exten_name; ImageMagickUtility::resize($source_name, 0, 120, $save_name); echo $x . " {$save_name} [OK] \n"; $x++; } }
/** * Search the specified directory tree with the specified pattern. Return an * array containing all matching files (no directories included). * * @param string $pattern the pattern to match every file with. * * @param string $directory the directory tree to search in. * * @param string $type the type of regular expression support to use, either * 'php' or 'perl'. * * @return array a list of files matching the pattern parameter in the the directory * path specified by the directory parameter * * @author Sterling Hughes <*****@*****.**> * @access public */ function &search($pattern, $directory, $type = 'php') { $matches = array(); list(, $files) = File_Find::maptree($directory); $match_function = File_Find::_determineRegex($pattern, $type); reset($files); while (list(, $entry) = each($files)) { if ($match_function($pattern, $entry)) { $matches[] = $entry; } } return $matches; }
/** * Search the specified directory tree with the specified pattern. Return * an array containing all matching files (no directories included). * * @param string $pattern the pattern to match every file with. * * @param string $directory the directory tree to search in. * * @param string $type the type of regular expression support to use, either * 'php' or 'perl'. * * @param bool $fullpath whether the regex should be matched against the * full path or only against the filename * * @return array a list of files matching the pattern parameter in the the * directory path specified by the directory parameter * * @author Sterling Hughes <*****@*****.**> * @access public */ function &search($pattern, $directory, $type = 'php', $fullpath = true) { /* if called statically */ /* TODO: this will fail if File_Find::search() is called inside */ /* instance of some other object */ if (!isset($this)) { $obj =& new File_Find(); return $obj->search($pattern, $directory, $type, $fullpath); } else { $matches = array(); list(, $files) = File_Find::maptree($directory); $match_function = File_Find::_determineRegex($pattern, $type); reset($files); while (list(, $entry) = each($files)) { if ($match_function($pattern, $fullpath ? $entry : basename($entry))) { $matches[] = $entry; } } } return $matches; }