{% else-1 %}
Класс наложения копирайта на изображение

                        
<?php
// Автор: Mr. Edward
class CopyrightImage
{
var $filename;
var $copyname;
var $src_w;
var $src_h;
var $dest_w;
var $dest_h;
var $src_img;
var $dest_img;
function __construct($fname, $copyfname)
{
$isa = getimagesize($fname);
$icsa = getimagesize($copyfname);
$this->filename = $fname;
$this->copyname = $copyfname;
$this->src_w = $isa[0];
$this->src_h = $isa[1];
$this->dest_w = $icsa[0];
$this->dest_h = $icsa[1];
if($isa[2]==3) $this->src_img = imagecreatefrompng($this->filename);
if($isa[2]==2) $this->src_img = imagecreatefromjpeg($this->filename);
if($isa[2]==1) $this->src_img = imagecreatefromgif($this->filename);
if($icsa[2]==3) $this->dest_img = imagecreatefrompng($this->copyname);
if($icsa[2]==2) $this->dest_img = imagecreatefromjpeg($this->copyname);
if($icsa[2]==1) $this->dest_img = imagecreatefromgif($this->copyname);
}
function copyright()
{
$dest_w_old=$this->dest_w;
$dest_h_old=$this->dest_h;
if (ceil($this->src_w/5)<=$this->dest_w)
{
$coef =ceil($this->dest_w/$this->src_w);
$this->dest_w =ceil($this->dest_w/($coef));
$this->dest_h =ceil($this->dest_h/($coef));
}
$x=$this->src_w-$this->dest_w;
$y=$this->src_h-$this->dest_h;
imagecopyresampled($this->src_img, $this->dest_img, $x, $y, 0, 0, $this->dest_w, $this->dest_h, $dest_w_old, $dest_h_old);
}
function conc()
{
header('Content-Type: image/png');
imagepng($this->src_img);
}
function __destruct()
{
imagedestroy($this->src_img);
imagedestroy($this->dest_img);
}
}
?>
Пример использования:
<?php
$object = new CopyrightImage('image.jpg', 'copyright.png');
$object->copyright();
$object->conc();
?>
0 17 0
0

Нет фото
abler98 * 22.68
• 30 июл 2013, 00:42


А у тебя есть класс для работы с файлами?*

0

Нет фото
• 30 июл 2013, 00:16


ооп *