bugzy Posted July 26, 2012 Share Posted July 26, 2012 I'm trying to resize an image on upload Here's the function <?php class SimpleImage { var $image; var $image_type; function me_resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); if( $this->image_type == IMAGETYPE_GIF || $this->image_type == IMAGETYPE_PNG ) { $current_transparent = imagecolortransparent($this->image); if($current_transparent != -1) { $transparent_color = imagecolorsforindex($this->image, $current_transparent); $current_transparent = imagecolorallocate($new_image, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); imagefill($new_image, 0, 0, $current_transparent); imagecolortransparent($new_image, $current_transparent); } elseif( $this->image_type == IMAGETYPE_PNG) { imagealphablending($new_image, false); $color = imagecolorallocatealpha($new_image, 0, 0, 0, 127); imagefill($new_image, 0, 0, $color); imagesavealpha($new_image, true); } } imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } ?> and I'm calling it like this <?php $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->me_resize(250,400); $image->save($_FILES['uploaded_image']['tmp_name']); ?> and I'm getting this error Fatal error: Call to undefined method SimpleImage::load() in C:\wamp\www\runa\admin\add_item.php on line 48 Any idea guys? Quote Link to comment https://forums.phpfreaks.com/topic/266257-fatal-error-call-to-undefined-method/ Share on other sites More sharing options...
jazzman1 Posted July 26, 2012 Share Posted July 26, 2012 You need to create this method "load" in your class Quote Link to comment https://forums.phpfreaks.com/topic/266257-fatal-error-call-to-undefined-method/#findComment-1364465 Share on other sites More sharing options...
bugzy Posted July 26, 2012 Author Share Posted July 26, 2012 my bad guys. now I get it. Quote Link to comment https://forums.phpfreaks.com/topic/266257-fatal-error-call-to-undefined-method/#findComment-1364467 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.