Jump to content

some major image display issues


Recommended Posts

Alrighty...here's the problem.  I have images on a server and stored in a database and i'd like to display them as thumbnails in the browser.  Every other time I've done this, I've saved thumbnail versions on the server.  I find this a waste of space and would like to figure out how to display them dynamically without having to save  individual versions.  I get to the point of using imagejpeg() to output it to the browser but the browser can not decode what's going on.  From my understanding i'm supposed to use "header("content-type: image/jpeg");" but i'm unclear as to where to put this because when i put it at the beginning before any output like it's supposed to be,  all that displays is the url of the current page on a blank white page.

 

any help?

 

currently i have an index file which includes show.php.  i have the header statement at the very beginning of the index.php

 

this is the display code from show.php

//make thumbnail of larger image
		list($width, $height, $type, $attr) = getimagesize($imagelink);

		//determine orientation of image
		if ($width >= $height) {
			$orientation = 0;
		}
		else {
			$orientation = 1;
		}

		$orig = imagecreatefromjpeg($imagelink);		

		// Set a maximum height and width
		if ($orientation == 0) {
			$thumbheight = 72;
			$thumbwidth  = 108;
		} else {
			$thumbheight = 97;
			$thumbwidth  = 82;
		}

		//create memory for thumbnail
		$thumb = imagecreatetruecolor($thumbwidth,$thumbheight);
		$fg = imagecolorallocate($thumb,255,255,255);
		imagefilledrectangle($thumb,0,0,100,75,$fg);


		//copy large image to thumbnail
		imagecopyresampled($thumb,$orig,0,0,0,0,$thumbwidth,$thumbheight,$width,$height);

		//write thumb to browser
		imagejpeg($thumb);

Link to comment
https://forums.phpfreaks.com/topic/86495-some-major-image-display-issues/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.