Announcement

Collapse
No announcement yet.

Wasserzeichen will nicht richtig

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wasserzeichen will nicht richtig

    Hallöchen,

    und zwar habe ich mit Hilfe von einem Freund es endlich geschafft ein Wasserzeichen beim upload druff zu klatschen

    Das Problem was ich nun habe ist folgendes.

    Das Script macht erst das Wasserzeichen drauf, und macht dann ein resize. Dies sollte allerdings andersrum sein, damit bei den Thumbs das Wasserzeichen immer gleichgroß ist.

    Zum Script muss ich dazu sagen. Es macht ein Thumb1 und ein Thumb2 sofern das Bild eine gewissen Größe überschreitet. Ansonsten ist Thumb2 = Orgiginalbild.

    Vielleicht mag einer das CMS PHP-Fusion kennen, da sieht die function creatthumbnail folgendermaßen aus, vielleicht wird der ein oder andere schlau draus.

    Code:
    function createthumbnail($filetype, $origfile, $thumbfile, $new_w, $new_h, $water = 'kein') {
    
    global $photosettings;
    
    
    if ($filetype == 1) { $origimage = imagecreatefromgif($origfile); }
    elseif ($filetype == 2) { $origimage = imagecreatefromjpeg($origfile); }
    elseif ($filetype == 3) { $origimage = imagecreatefrompng($origfile); }
    ////
    
    
    if($water != 'kein')
    {
    	
    	if($water == 'hell')
    	{
    		$watermark = ImageCreateFromPNG( BASEDIR . 'images/watermark_hell.png');
    	}
    	else if($water == 'dunkel')
    	{
    		$watermark = ImageCreateFromPNG( BASEDIR . 'images/watermark_dunkel.png');
    	}
    			
    	if($new_w > $photosettings['thumb_w'])
    	{
    	ImageCopy($origimage, $watermark, imagesx($origimage)-imagesx($watermark), imagesy($origimage)-imagesy($watermark), 0, 0, imagesx($watermark), imagesy($watermark));
    	}
    }
    /////
    
    $old_x = imagesx($origimage);
    $old_y = imagesy($origimage);
    
    if ($old_x > $new_w || $old_y > $new_h) {
    if ($old_x < $old_y) {
    $thumb_w = round(($old_x * $new_h) / $old_y);
    $thumb_h = $new_h;
    } elseif ($old_x > $old_y) {
    $thumb_w = $new_w;
    $thumb_h = round(($old_y * $new_w) / $old_x);
    } else {
    $thumb_w = $new_w;
    $thumb_h = $new_h;
    }
    } else {
    $thumb_w = $old_x;
    $thumb_h = $old_y;
    }
    
    if ($photosettings['thumb_compression'] == "gd1") {
    $thumbimage = imagecreate($thumb_w,$thumb_h);
    $result = imagecopyresized($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    } else {
    $thumbimage = imagecreatetruecolor($thumb_w,$thumb_h);
    $result = imagecopyresampled($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    }
    
    touch($thumbfile);
    
    if ($filetype == 1) { imagegif($thumbimage, $thumbfile); }
    elseif ($filetype == 2) { imagejpeg($thumbimage, $thumbfile, 100); }
    elseif ($filetype == 3) { imagepng($thumbimage, $thumbfile); }
    
    }
    
    function image_exists($dir, $image) {
    	$i = 1;
    	$image_name = substr($image, 0, strrpos($image, "."));
    	$image_ext = strrchr($image,".");
    	while (file_exists($dir.$image)) {
    		$image = $image_name."_".$i.$image_ext;
    		$i++;
    	}
    	return $image;
    }
    Das eigentliche was mich stört ist, das er ein Wasserzeichen auf dem dem kleinsten Thumb macht, was nicht so sein soll.

    Desweiteren soll er halt erst resizen und dann erst das Wasserzeichen drauf machen.


    mfg
    benny
Working...
X