php批量处理图片大小

 
更多
<?php
require_once (dirname ( __FILE__ ) . "/include/common.inc.php");
require_once ("/admin/inc/inc_archives_functions.php");
function myscandir($path) {
	$mydir = dir ( $path );
	while ( $file = $mydir->read () ) {
		$p = $path . '/' . $file;
		if (($file != ".") and ($file != "..")) {
			$file_arr [] = $p;
		}
		if ((is_dir ( $p )) and ($file != ".") and ($file != "..")) {
			myscandir ( $p );
		}
	}
	return $file_arr;
}
$file_arr = myscandir ( 'F:/3g_88353588_net/uploads/allimg/130805' );
foreach ( $file_arr as $file ) {
	list ( $width, $height ) = getimagesize ( $file );
	//echo $file . '->' . $width . '*' . $height . '<hr/>';
	$max_width = 300;
	if ($width > $max_width) {
		$ratio = round ( $width / $max_width, 2 );
		$ToHeight = round ( $height / $ratio, 2 );
		ImageResize ( $file, $max_width, $ToHeight );
		list ( $width, $height ) = getimagesize ( $file );
		echo $file . '->' . $width . '*' . $height . '<hr/>';
	}
}

/*
 * list ( $width, $height ) = getimagesize ( "87973926602.jpg" ); $max_width =
 * 300; $ratio = round ( $width / $max_width, 2 ); $ToHeight = round ( $height /
 * $ratio, 2 ); ImageResize ( $value, $max_width, $ToHeight );
 */

?>


打赏

本文固定链接: https://www.cxy163.net/archives/932 | 绝缘体

该日志由 绝缘体.. 于 2013年08月07日 发表在 学东西 分类下,
原创文章转载请注明: php批量处理图片大小 | 绝缘体

报歉!评论已关闭.