
Zitat von
Taney
Die beste Möglichkeit wäre es, wie buffy schon schreibt per Resize das einzustellen, nur läuft unsere Community auf .jsp Basis.
Am besten wäre es, wenn man beim Upload eine bestimmte Größe erzwingen könnte, bzw. die User laden ein Bild in ein Vorschaufenster hoch und haben ein Rechteck zur Verfügung, mit der Sie über das Bild fahren und das Bild abschneiden können. (Ich hoffe, ich habe es verständlich erklärt?

)
Viele Grüße aus Stuttgart
Taner
man nehme ganz einfach js für die auswahl des bereiches
und man schreibt diese funktion in jsp um..
PHP-Code:
thumb("grafik.jpg","image/jpeg", 'jpg',247,343, $file ,100 );
function thumb($srcFile, $srcType, $dstType, $dstWidth, $dstHeight, $dstPath,$quality=90)
{
if ($srcType == "image/jpeg")
$handle = imagecreatefromjpeg($srcFile);
else if ($srcType == "image/png")
$handle = imagecreatefrompng($srcFile);
else if ($srcType == "image/gif")
$handle = imagecreatefromgif($srcFile);
else
return false;
if (!$handle)
return false;
$srcWidth = imagesx($handle);
$srcHeight = imagesy($handle);
if ($srcWidth >= $dstWidth && $srcHeight >= $dstHeight)
{
$newHandle = imagecreatetruecolor($dstWidth, $dstHeight);
if (!$newHandle)
return false;
if($srcHeight < $srcWidth)
{
$ratio = (double)($srcHeight / $dstHeight);
$cpyWidth = round($dstWidth * $ratio);
if ($cpyWidth > $srcWidth)
{
$ratio = (double)($srcWidth / $dstWidth);
$cpyWidth = $srcWidth;
$cpyHeight = round($dstHeight * $ratio);
$xOffset = 0;
$yOffset = round(($srcHeight - $cpyHeight) / 2);
} else {
$cpyHeight = $srcHeight;
$xOffset = round(($srcWidth - $cpyWidth) / 2);
$yOffset = 0;
}
} else {
$ratio = (double)($srcWidth / $dstWidth);
$cpyHeight = round($dstHeight * $ratio);
if ($cpyHeight > $srcHeight)
{
$ratio = (double)($srcHeight / $dstHeight);
$cpyHeight = $srcHeight;
$cpyWidth = round($dstWidth * $ratio);
$xOffset = round(($srcWidth - $cpyWidth) / 2);
$yOffset = 0;
} else {
$cpyWidth = $srcWidth;
$xOffset = 0;
$yOffset = round(($srcHeight - $cpyHeight) / 2);
}
}
if (!imagecopyresampled($newHandle, $handle, 0, 0, $xOffset, $yOffset, $dstWidth, $dstHeight, $cpyWidth, $cpyHeight))
return false;
imagedestroy($handle);
if( $dstWidth <= 150 ){
#$newHandle = set_sharpnes( $newHandle, $dstWidth, $dstHeight );
}
// $newHandle = contrast($newHandle,$dstWidth,$dstHeight );
if ($dstType == "png")
imagepng($newHandle, $dstPath);
else if ($dstType == "jpg")
imagejpeg($newHandle, $dstPath, $quality);
else if ($dstType == "gif")
imagegif($newHandle, $dstPath);
else
return false;
imagedestroy($newHandle);
return true;
} else {
return "Sorry aber .... ";
}
}