0

hi,

I need php mysql image upload and resizer.
The image uploaded through a uploading page should be resized and should kept in mysql server. and we need to retrieve it to another page. help me.

thanks,

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by qazplm114477
0

hi,

I need php mysql image upload and resizer.
The image uploaded through a uploading page should be resized and should kept in mysql server. and we need to retrieve it to another page. help me.

thanks,

This link shows most of what you need

http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop-v11/

for the demo

http://www.webmotionuk.co.uk/jquery/image_upload_crop.php

the code doesn't use any database but it does have a nice function about resizing images.

//sample from the code linked above
function resizeImage($image,$width,$height,$scale) {
	list($imagewidth, $imageheight, $imageType) = getimagesize($image);
	$imageType = image_type_to_mime_type($imageType);
	$newImageWidth = ceil($width * $scale);
	$newImageHeight = ceil($height * $scale);
	$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
	switch($imageType) {
		case "image/gif":
			$source=imagecreatefromgif($image); 
			break;
	    case "image/pjpeg":
		case "image/jpeg":
		case "image/jpg":
			$source=imagecreatefromjpeg($image); 
			break;
	    case "image/png":
		case "image/x-png":
			$source=imagecreatefrompng($image); 
			break;
  	}
	imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
	
	switch($imageType) {
		case "image/gif":
	  		imagegif($newImage,$image); 
			break;
      	case "image/pjpeg":
		case "image/jpeg":
		case "image/jpg":
	  		imagejpeg($newImage,$image,90); 
			break;
		case "image/png":
		case "image/x-png":
			imagepng($newImage,$image);  
			break;
    }
	
	chmod($image, 0777);
	return $image;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.