Beste mensen,

Ik had 'n scriptje van 't web gehaald en dat zelf zo dusdanig aangepast dat het redelijk goed werkt. Het enige is dus op 't moment dat de foto niet geresized hoef te worden van 't origineel is er niets aan de hand maar op t moment deze verkleind moet worden krijg ik een anderen thumbnail met een zwarte vlek dr in. (http://www.delanowebworx.nl/upload/thumb_P9062122_640x480.jpg) bijvoorbeeld. Hoe is dit op te lossen, ik heb geen flauw idee.


<?php
if(isset($_POST['submit'])) {
	if(isset($_FILES['new_image'])) {
		$target						= "gallerij/images/" . $_FILES['new_image']['name'];
		move_uploaded_file($_FILES['new_image']['tmp_name'], $target);

		list($width, $height)		= getimagesize($target);

		$modwidth					= 500;
		$modheight					= 333;

		if($width > $modwidth) {
			$tn							= imagecreatetruecolor($modwidth, $modheight);
			$image						= imagecreatefromjpeg($target);
			imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);

			imagejpeg($tn, $target, 100);
		} else {
			$tn							= imagecreatetruecolor($modwidth, $modheight);
			$image						= imagecreatefromjpeg($target);
			imagecopyresampled($tn, $image, 0, 0, 0, 0, $width, $modheight, $width, $height);

			imagejpeg($tn, $target, 100);
		}

		$save							= "gallerij/images/thumb_" . $_FILES['new_image']['name']; //This is the new file you saving

		$modwidth						= 75;
		$modheight						= 50;

		$tn								= imagecreatetruecolor($modwidth, $modheight);
		$image							= imagecreatefromjpeg($target);
		imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);

		imagejpeg($tn, $save, 100);

	}
}
			 
?>
Dit komt je $tn groter is dan waar je je image naar toe resized...

Reageren