Jump to content

creating thumnails with gd


nobodyk

Recommended Posts

Can anyone guide me on how to create thumbnails with php/gd. I'm trying to use gd to create thumbnails and then store in in my server. I'm currently using a function in my script, but some thumbnails come out black.

 

Here's part of the code:

			if (($extension == "jpeg") || ($extension == "jpg")) $originalImage = ImageCreateFromJPEG($sourceImagePath);
			elseif ($extension == "gif") $originalImage = ImageCreateFromGIF($sourceImagePath);
			elseif ($extension == "png") $originalImage = ImageCreateFromPNG($sourceImagePath);
			elseif($extension == "bmp") $originalImage = ImageCreateFromWBMP($sourceImagePath);  // removed since Windows BMP is not supported
			$newImage = ImageCreateTrueColor($new_x, $new_y);
			ImageCopyResampled($newImage, $originalImage, 0, 0, $srcx, $srcy, $new_x, $new_y, $srcw, $srch);

			ImageJPEG($newImage, $imagePath, $outputImageQuality);
			ImageDestroy($newImage);
			ImageDestroy($originalImage);

Link to comment
https://forums.phpfreaks.com/topic/210521-creating-thumnails-with-gd/
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.