Home > Backend Development > PHP Tutorial > Thumbnail generation php program

Thumbnail generation php program

高洛峰
Release: 2023-03-02 20:30:01
Original
1048 people have browsed it

Page uploaded by client:

-------------------- upload.htm ------------------ ---


method="post" action="upload.php">

Please select or enter the upload file name:



-- ------------------- upload.php -------------------

if(empty ($upfile)){

print("No file was transferred!nNo file uploaded!");

exit;

}

$image_path=$upfile;

@$image_info=getimagesize($image_path) ;

if($image_info[2]==2)

{@$image2=imagecreatefromjpeg($image_path);

}

else if($image_info[2]==1){

@$image2 =imagecreatefromgif($image_path);

}

else

if(empty($image2))

$image2_x=imagesx($image2);

$image2_y=imagesy($image2);

if($ image2_x==$image2_y){

$x=150;

$y=0;

}

else if($image2_x>$image2_y){

$x=150;

$y=intval( 150*$image2_y/$image2_x);

}

else{

$y=150;

$x=intval(150*$image2_x/$image2_y);

}

$image1=imagecreate($ x,$y);

imagecopyresized($image1,$image2,0,0,0,0,$x,$y,$image2_x,$image2_y);

imagegif($image1,"new.gif") ;

?>

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template