note 108266 added to function.imagecopy
| From: | (kansiz@gmail.com) | Date: | Thu, 12 Apr 2012 22:06:31 +0000 |
| Subject: | note 108266 added to function.imagecopy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187091@lists.php.net to get a copy of this message | ||
<?php
function InsertImage($D){
$Type = getimagesize($D[Image]);
$Width = $Type[0];
$Height = $Type[1];
if(($Width < $D[Width]) and ($Width >= $Height)){
$D[Width] = $Width+20;
$D[Height] = $Width+20;
}elseif(($Height < $D[Height]) and ($Height >= $Width)){
$D[Width] = $Height+20;
$D[Height] = $Height+20;
}
if(!$D[Width]) {
$D[Width] = $Width;
}
if(!$D[Height]) {
$D[Height] = $Height;
}
if(!$D[Size]) {
$D[Size] = "2048";
}
if(($Type[mime] != "image/jpeg") and ($Type[mime] != "image/gif") and
($Type[mime] != "image/png")){
$C[Error][] = "File format is not.";
}
if(filesize($D[Image]) > ($D[Size] * 1024)){
$C[Error][] = "Image size is larger (".($D[Size])." kb).";
}
if(!is_array($C[Error])){
if($Width > $D[Width]){
$Height = round($Height / ($Width / $D[Width]));
$Width = $D[Width];
}
if($Height > $D[Height]){
$Width = round($Width / ($Height / $D[Height]));
$Height = $D[Height];
}
if($Width < $D[Width]){
$OWidth = round(($D[Width] - $Width) / 2);
}
if($Height < $D[Height]){
$OHeight = round(($D[Height] - $Height) / 2);
}
if($D[Type] == "Standart"){
$Background = imagecreatetruecolor($D[Width],$D[Height]);
}elseif($D[Type] == "Original"){
$Background = imagecreatetruecolor($Type[0],$Type[1]);
}
if($D[Background] == "Black"){
$Renk = imagecolorallocate($Background,0,0,0);
}else{
$Renk = imagecolorallocate($Background,255,255,255);
}
imagefill($Background,0,0,$Renk);
if($Type[mime] == "image/jpeg"){
$Source = imagecreatefromjpeg($D[Image]);
}elseif($Type[mime] == "image/gif"){
$Source = imagecreatefromgif($D[Image]);
}elseif($Type[mime] == "image/png"){
$Source = imagecreatefrompng($D[Image]);
}
if($D[Thumbss]){
$On = imagecreatefrompng($D[Thumb]);
$ox = imagesx($On);
$oy = imagesy($On);
imagecopymerge($Source,$On,($Type[0] - $ox) - 10,($Type[1] - $oy) - 10,0,0,$ox,$oy,50);
}
if($D[Type] == "Standart"){
imagecopyresampled($Background,$Source,$OWidth,$OHeight,0,0,$Width,$Height,$Type[0],$Type[1]);
}elseif($D[Type] == "Original"){
imagecopyresampled($Background,$Source,0,0,0,0,$Type[0],$Type[1],$Type[0],$Type[1]);
}
if(!$D[Quality]) {
$D[Kalite] = "100";
}
imageJPEG($Background,$D[Target],$D[Quality]);
$C["Return"] = "Succesfull";
}else{
$C["Return"] = "Error";
}
return $C;
}
$IMAGE_SMALL = InsertImage(Array("Image" =>
"/var/www/tmp/".$_SESSION["oncesisonrasiresim"],
"Target" =>
"/var/www/images/".$YENIID."-150.jpg",
"Type" => "Standart",
"Quality" => "100",
"Size" => "1024",
"Width" => "150",
"Height" => "100",
"Background" => "Beyaz",
"Thumb" => "/var/www/thumb.png"));
$IMAGE_LARGE = InsertImage(Array("Image" =>
"/var/www/tmp/".$_SESSION["oncesisonrasiresim"],
"Target" =>
"/var/www/images/".$YENIID."-600.jpg",
"Type" => "Standart",
"Quality" => "100",
"Size" => "1024",
"Width" => "600",
"Height" => "400",
"Background" => "Beyaz",
"Thumb" => "/var/www/thumb.png"));
?>
----
Server IP: 160.75.100.7
Probable Submitter: 95.6.81.103
----
Manual Page -- http://www.php.net/manual/en/function.imagecopy.php
Edit -- https://master.php.net/note/edit/108266
Del: integrated -- https://master.php.net/note/delete/108266/integrated
Del: useless -- https://master.php.net/note/delete/108266/useless
Del: bad code -- https://master.php.net/note/delete/108266/bad+code
Del: spam -- https://master.php.net/note/delete/108266/spam
Del: non-english -- https://master.php.net/note/delete/108266/non-english
Del: in docs -- https://master.php.net/note/delete/108266/in+docs
Del: other reasons-- https://master.php.net/note/delete/108266
Reject -- https://master.php.net/note/reject/108266
Search -- https://master.php.net/manage/user-notes.php