<?php
# Copyright by Manuel
# Support www.ilch.de
defined (
'main'
)
or
die
(
'no direct access'
);
function
create_thumb (
$imgpath
,
$thumbpath
,
$neueBreite
) {
$size
=
getimagesize
(
$imgpath
);
$breite
=
$size
[0];
$hoehe
=
$size
[1];
$neueBreite
=
intval
(
$breite
*100/
$hoehe
);
if
(
$size
[2] < 2 OR
$size
[2] > 3) {
return
(FALSE); }
if
(
$size
[2] == 2) {
$altesBild
= imagecreatefromjpeg(
$imgpath
);
}
elseif
(
$size
[2] == 3 ) {
$altesBild
= imagecreatefrompng(
$imgpath
);
}
if
( function_exists (
'imagecreatetruecolor'
) ) {
$neuesBild
= imagecreatetruecolor(
$neueBreite
,100);
imagecopyresampled(
$neuesBild
,
$altesBild
, 0, 0, 0, 0,
$neueBreite
,100,
$breite
,
$hoehe
);
}
else
{
$neuesBild
=imageCreate(
$neueBreite
,100);
imageCopyResized(
$neuesBild
,
$altesBild
,0,0,0,0,
$neueBreite
,100,
$breite
,
$hoehe
);
}
if
(
$size
[2] == 2) {
ImageJPEG(
$neuesBild
,
$thumbpath
);
}
elseif
(
$size
[2] == 3 ) {
ImagePNG(
$neuesBild
,
$thumbpath
);
}
return
(TRUE);
}
?>