ABZiko
پنج شنبه 23 بهمن 1393, 00:28 صبح
سلام، بنده یک کلاس ساختم با کد زیر :
<?php
class CreatingImage{
public function createImage($width,$height){
return imagecreate($width,$height);}
public function imageColor($img,$red,$green,$blue){
return imagecolorallocate($img,$red,$green,$blue);}
public function imageType($img,$png,$jpg,$gif){
$success=false;
if(imagepng($img)){
$png=imagepng($img);
return $png;
$success=true;}
if(imagejpeg($img)){
$jpg=imagejpeg($img);
return $jpg;
$success=true;}
if(imagegif($img)){
$gif=imagegif($img);
return $gif;
$success=true;}}
public function createText($img,$size,$angle,$x,$y,$textColor,$fon t,$text){
imagettftext($img,$size,$angle,$x,$y,$textColor,$f ont,$text);}}
?>
و این هم صفحه دیگه ای هست که کلاس بالا رو در اون فراخوانی می کنم :
<title>Creating an Image</title>
<?php
require_once('CreatingImage.php');
$obj=new CreatingImage();
$img=$obj->createImage(200,200);
$obj->imageColor($img,200,200,200);
$obj->imageType($img,true,false,false);
/*$textColor=imagecolorallocate($img,150,100,50);
$obj->createText($img,20,20,20,20,$textColor,"Segoe UI.ttf",rand(111,999));*/
imagepng($img);
?>
اما موقع اجرا اروری نمی ده، فقط می نویسه :
‰PNG IHDRÈÈ—–<ÝPLTEÈÈÈ®ZíæIDATX…íÁà ùS_áU|PeÕÇIEND®B`‚‰PNG IHDRÈÈ—–<ÝPLTEÈÈÈ®ZíæIDATX…íÁà ùS_áU|PeÕÇIEND®B`‚‰PNG IHDRÈÈ—–<ÝPLTEÈÈÈ®ZíæIDATX…íÁà ùS_áU|PeÕÇIEND®B`‚
این ها چی هستن؟
<?php
class CreatingImage{
public function createImage($width,$height){
return imagecreate($width,$height);}
public function imageColor($img,$red,$green,$blue){
return imagecolorallocate($img,$red,$green,$blue);}
public function imageType($img,$png,$jpg,$gif){
$success=false;
if(imagepng($img)){
$png=imagepng($img);
return $png;
$success=true;}
if(imagejpeg($img)){
$jpg=imagejpeg($img);
return $jpg;
$success=true;}
if(imagegif($img)){
$gif=imagegif($img);
return $gif;
$success=true;}}
public function createText($img,$size,$angle,$x,$y,$textColor,$fon t,$text){
imagettftext($img,$size,$angle,$x,$y,$textColor,$f ont,$text);}}
?>
و این هم صفحه دیگه ای هست که کلاس بالا رو در اون فراخوانی می کنم :
<title>Creating an Image</title>
<?php
require_once('CreatingImage.php');
$obj=new CreatingImage();
$img=$obj->createImage(200,200);
$obj->imageColor($img,200,200,200);
$obj->imageType($img,true,false,false);
/*$textColor=imagecolorallocate($img,150,100,50);
$obj->createText($img,20,20,20,20,$textColor,"Segoe UI.ttf",rand(111,999));*/
imagepng($img);
?>
اما موقع اجرا اروری نمی ده، فقط می نویسه :
‰PNG IHDRÈÈ—–<ÝPLTEÈÈÈ®ZíæIDATX…íÁà ùS_áU|PeÕÇIEND®B`‚‰PNG IHDRÈÈ—–<ÝPLTEÈÈÈ®ZíæIDATX…íÁà ùS_áU|PeÕÇIEND®B`‚‰PNG IHDRÈÈ—–<ÝPLTEÈÈÈ®ZíæIDATX…íÁà ùS_áU|PeÕÇIEND®B`‚
این ها چی هستن؟