<?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);
}
}
}
}

相关文章:

  • 2021-12-16
  • 2021-06-14
  • 2021-12-27
  • 2022-01-02
  • 2021-12-26
  • 2022-01-06
  • 2021-11-02
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2021-12-30
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案