class
InsertLogo
{
private
$source
;
private
$logo
;
private
$source_type
;
private
$logo_type
;
private
$source_width
;
private
$source_height
;
private
$logo_width
;
private
$logo_height
;
private
$tinyImage_width
;
private
$tinyImage_height
;
private
$newPicPath
;
private
$tinyImagePath
;
function
__construct(
$source
,
$logo
)
{
$this
->source=
$source
;
$info
=
GetImageSize
(
$source
);
$this
->source_width=
$info
[0];
$this
->source_height=
$info
[1];
$this
->source_type_id=
$info
[2];
$this
->source_type=
$info
['mime'];
$this
->logo=
$logo
;
$info
=
GetImageSize
(
$logo
);
$this
->logo_width=
$info
[0];
$this
->logo_height=
$info
[1];
$this
->logo_type_id=
$info
[2];
$thi
->logo_type=
$logo
['mime'];
}
function
JudgeTypeAndDeal(
$type
,
$source
)
{
if
(
$type
==1)
{
return
ImageCreateFromGIF(
$source
);
}
else
if
(
$type
==2)
{
return
ImageCreateFromJPEG(
$source
);
}
else
{
return
ImageCreateFromPNG(
$source
);
}
}
function
CreateLogoImage()
{
$this
->source=
$this
->JudgeTypeAndDeal(
$this
->source_type_id,
$this
->source);
$this
->logo=
$this
->JudgeTypeAndDeal(
$this
->logo_type_id,
$this
->logo);
$x
=
$this
->source_width-
$this
->logo_width;
$y
=
$this
->source_height-
$this
->logo_height;
$w
=
$this
->logo_width;
$h
=
$this
->logo_height;
ImageCopy(
$this
->source,
$this
->logo,
$x
,
$y
,0,0,
$w
,
$h
)
or
die
(
"fail to combine"
);
$this
->newPicPath='App/Upload/image/normal/1108000627/
new
.jpg';
ImageJpeg(
$this
->source,'
new
.jpg');
rename('
new
.jpg',
$this
->newPicPath);
}
function
CreateTinyImage()
{
$TinyImage
=imagecreatetruecolor(
$this
->source_width*0.3,
$this
->source_height*0.3);
$this
->source=
$this
->JudgeTypeAndDeal(
$this
->source_type_id,
$this
->source);
ImageCopyResized(
$TinyImage
,
$this
->source,0,0,0,0,
$this
->source_width*0.3,
$this
->source_height*0.3,
$this
->source_width,
$this
->source_height)
or
die
(
"fail"
);
$this
->tinyImagePath='App/Upload/image/tiny/1108000627/
new
.jpg';
ImageJpeg(
$TinyImage
,'
new
.jpg');
rename('
new
.jpg',
$this
->tinyImagePath);
}
}