<span>php
</span><span>
class
</span><span> Image
{
</span><span>
private
</span><span>
$info
;
</span><span>
private
</span><span>
$image
;
</span><span>
public
</span><span>
$type
;
</span><span>
public
</span><span>
function
__construct(
$src
)
{
$</span><span>this</span>->info=<span>
getimagesize
(
$src
);
$</span><span>this</span>->type=image_type_to_extension($<span>this</span>->info[<span>
'</span><span>2</span><span>'
</span>],<span>false</span><span>);
$fun
</span>=<span>
"</span><span>imagecreatefrom{$this->type}</span><span>"
</span><span>;
$</span><span>this</span>->image=<span>
$fun
(
$src
);
}
</span><span>
</span><span>
public
</span>
function
fontMark(
$font
,
$content
,
$size
,
$col
,
$location
,
$angle
=<span>0</span><span>){
$col
</span>=imagecolorallocatealpha($<span>this</span>->image,
$col
[<span>
'</span><span>0</span><span>'
</span>],
$col
[<span>
'</span><span>1</span><span>'
</span>],
$col
[<span>
'</span><span>2</span><span>'
</span>],
$col
[<span>
'</span><span>3</span><span>'
</span><span>]);
imagettftext($</span><span>this</span>->image,
$size
,
$angle
,
$location
[<span>
'</span><span>0</span><span>'
</span>],
$location
[<span>
'</span><span>1</span><span>'
</span><span>],
$col
,
$font
,
$content
);
}
</span><span>
</span><span>
public
</span><span>
function
imageMark(
$imageMark
,
$dst
,
$pct
){
$info2
</span>=<span>
getimagesize
(
$imageMark
);
$type
</span>=image_type_to_extension(
$info2
[<span>
'</span><span>2</span><span>'
</span>],<span>false</span><span>);
$func2
</span>=<span>
"</span><span>imagecreatefrom</span><span>"
</span><span>.
$type
;
$water
</span>=<span>
$func2
(
$imageMark
);
imagecopymerge($</span><span>this</span>->image,
$water
,
$dst
[<span>0</span>],
$dst
[<span>1</span>], <span>0</span>, <span>0</span>,
$info2
[<span>
'</span><span>0</span><span>'
</span>],
$info2
[<span>
'</span><span>1</span><span>'
</span><span>],
$pct
);
imagedestroy(
$water
);
}
</span><span>
</span><span>
public
</span><span>
function
thumb(
$thumbSize
){
$imageThumb
</span>=imagecreatetruecolor(
$thumbSize
[<span>0</span>],
$thumbSize
[<span>1</span><span>]);
imagecopyresampled(
$imageThumb
, $</span><span>this</span>->image, <span>0</span>, <span>0</span>, <span>0</span>, <span>0</span>,
$thumbSize
[<span>0</span>],
$thumbSize
[<span>1</span>], $<span>this</span>->info[<span>
'</span><span>0</span><span>'
</span>], $<span>this</span>->info[<span>
'</span><span>1</span><span>'
</span><span>]);
imagedestroy($</span><span>this</span>-><span>image);
$</span><span>this</span>->image=<span>
$imageThumb
;
}
</span><span>
</span><span>
public
</span><span>
function
cut(
$cutSize
,
$location
){
$imageCut
</span>=imagecreatetruecolor(
$cutSize
[<span>0</span>],
$cutSize
[<span>1</span><span>]);
imagecopyresampled(
$imageCut
, $</span><span>this</span>->image, <span>0</span>, <span>0</span>,
$location
[<span>0</span>],
$location
[<span>1</span>],
$cutSize
[<span>0</span>],
$cutSize
[<span>1</span>],
$cutSize
[<span>0</span>],
$cutSize
[<span>1</span><span>]);
imagedestroy($</span><span>this</span>-><span>image);
$</span><span>this</span>->image=<span>
$imageCut
;
}
</span><span>
</span><span>
public
</span><span>
function
show(){
header(</span><span>
"</span><span>content-type:</span><span>"
</span>.$<span>this</span>->info[<span>
'</span><span>mime</span><span>'
</span><span>]);
$funn
</span>=<span>
"</span><span>image</span><span>"
</span>.$<span>this</span>-><span>type;
$funn
($</span><span>this</span>-><span>image);
}
</span><span>
</span><span>
public
</span><span>
function
save(
$newname
){
header(</span><span>
"</span><span>content-type:</span><span>"
</span>.$<span>this</span>->info[<span>
'</span><span>mime</span><span>'
</span><span>]);
$funn
</span>=<span>
"</span><span>image</span><span>"
</span>.$<span>this</span>-><span>type;
$funn
($</span><span>this</span>->image,
$newname
.<span>
'</span><span>.</span><span>'
</span>.$<span>this</span>-><span>type);
}
</span><span>
public
</span><span>
function
__destruct(){
imagedestroy($</span><span>this</span>-><span>image);
}
}
</span>?>