首页 > Web开发 > 详细

php 修改图片大小

时间:2019-03-08 12:20:18      阅读:151      评论:0      收藏:0      [点我收藏+]

<?php
set_time_limit(0);
ini_set("memory_limit","500M");
$dir = dir(‘./‘);
while (false!==($e=$dir->read())) {
if (is_dir($e)) {
$dir1 = dir($e);
while (false!==($b=$dir1->read())) {


$file = explode(‘.‘, $b);
$ext = end($file);
if ($ext==‘jpg‘||$ext==‘png‘) {

$arr = getimagesize($e.‘/‘.$b);
// print_r($arr);die;
if ($arr[‘mime‘]==‘image/png‘) {
$src = ImageCreateFromPNG($e.‘/‘.$b);

}else{
$src = ImageCreateFromJPEG($e.‘/‘.$b);
}
// $src = ImageCreateFromJPEG($b);
$width = ImageSx($src);
$height = ImageSy($src);
$x = 750;
$y = 750;
$dst = ImageCreateTrueColor($x,$y);
ImageCopyResampled($dst,$src,0,0,0,0,$x,$y,$width,$height);
if ($arr[‘mime‘]==‘image/png‘) {
header(‘Content-Type : image/png‘);
ImagePNG($dst,$e.‘/‘.$b);
}
header(‘Content-Type : image/jpeg‘);
Imagejpeg($dst,$e.‘/‘.$b);
}
}
}
}

php 修改图片大小

原文:https://www.cnblogs.com/zhaoxiangshang/p/10494959.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!