Bilder verkleinern und per FTP Hochladen

Matthiasghh

Mitglied
Hallo Leute,
habe wieder mal ein Problem.
Ich möchte mehrere Bilder hochladen aber vorher möchte ich diese Bilder verkleinern.
auf bestimmte maße. am besten mit Gd2.

PHP:
$result = mysql_query("select id from pics"); 
while ($row = mysql_fetch_object($result))
{
$id     = $row->id;
$fotoname = "$pic$id$savecode.jpg";
}
$conn_ftp = ftp_connect($HOST1); 
@ftp_login($conn_ftp,$ID1,$PW1);
@ftp_chdir($conn_ftp,$PFAD1);
$mode = FTP_BINARY;
$file = fopen($HTTP_POST_FILES['bild']['tmp_name'],"r");
@ftp_fput($conn_ftp,$fotoname,$file,$mode);
fclose($file);
ftp_quit($conn_ftp);
move_uploaded_file(($HTTP_POST_FILES['bild']['tmp_name']),"../../pics/$fotoname"); chmod ("../../pics/$fotoname", 0777);]
function thumb($file, $save, $width, $height, $prop = TRUE) {
    @unlink($save);
    $infos = @getimagesize($file);
    if($prop) {
        // Proportionen erhalten
        $iWidth = $infos[0];
        $iHeight = $infos[1];
        $iRatioW = $width / $iWidth;
        $iRatioH = $height / $iHeight;
        if ($iRatioW < $iRatioH)
        {
        $iNewW = $iWidth * $iRatioW;
        $iNewH = $iHeight * $iRatioW;
        } else {
        $iNewW = $iWidth * $iRatioH;
        $iNewH = $iHeight * $iRatioH;
        } // end if
    } else {
        // Strecken und Stauchen auf Größe
        $iNewW = $width;
        $iNewH = $height;
    }
    if($infos[2] == 2) {
        // Bild ist vom Typ jpg
        $imgA = imagecreatefromjpeg($file);
        $imgB = imagecreatetruecolor($iNewW,$iNewH);
        imagecopyresampled($imgB, $imgA, 0, 0, 0, 0, $iNewW,
                           $iNewH, $infos[0], $infos[1]);
        imagejpeg($imgB, $save);
    } elseif($infos[2] == 3) {
        // Bild ist vom Typ png
        $imgA = imagecreatefrompng($file);
        $imgB = imagecreatetruecolor($iNewW, $iNewH);
        imagecopyresampled($imgB, $imgA, 0, 0, 0, 0, $iNewW,
                           $iNewH, $infos[0], $infos[1]);
        imagepng($imgB, $save);
    } else {
        return FALSE;
    }
}
// Quelldatei
$from = "./../../pics/$fotoname";
$to1 = "./../../small_pics/thumb_$fotoname";
$to2 = "./../../small_pics/thumb_v$fotoname";
thumb($from, $to1, 75, 95, TRUE);
thumb($from, $to2, 110, 164, TRUE);

Das funktionert auch das Hochladen mit verkleinerung möchte mehr Bilder hochladen mit verkleinerung.

:) Vielen Dank für eure Hilfe :)
 
Zuletzt bearbeitet:
Hi

ich denke, dass Du hier im falschen Board bist. ASP kennt meines Wissens nichts von Gd. Dort gibts fürs Verändern der Images entspr. Komponenten genauso wie für das Upload derselben.
 
Zurück