whirlpool6 Posted September 4, 2007 Share Posted September 4, 2007 hello guys... i have the following codes but no image is seen... <?php // The file you are resizing $file = 'D:\public\try.jpg'; //This will set our output to 45% of the original size $size = 0.45; // This sets it to a .jpg, but you can change this to png or gif header('Content-type: image/jpeg'); // Setting the resize parameters list($width, $height) = getimagesize($file); $modwidth = $width * $size; $modheight = $height * $size; // Creating the Canvas $tn= imagecreatetruecolor($modwidth, $modheight); $source = imagecreatefromjpeg($file); // Resizing our image to fit the canvas imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); // Outputs a jpg image, you could change this to gif or png if needed imagejpeg($tn); ?> and <?php // The file $filename = 'D:\public\try.jpg'; $percent = 0.5; // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width, $height) = getimagesize($filename); $new_width = $width * $percent; $new_height = $height * $percent; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Output imagejpeg($image_p); ?> i only copied them from tutorials but they are not working... what is possibly wrong? i already have gd2 in my php. thansk a lot Quote Link to comment https://forums.phpfreaks.com/topic/67871-image-imagecopyresized-and-imagecopyresampled-problems/ Share on other sites More sharing options...
vijayfreaks Posted September 4, 2007 Share Posted September 4, 2007 Hi... r u getting any error..? if yes then show ur error? -Vijay Quote Link to comment https://forums.phpfreaks.com/topic/67871-image-imagecopyresized-and-imagecopyresampled-problems/#findComment-341172 Share on other sites More sharing options...
whirlpool6 Posted September 4, 2007 Author Share Posted September 4, 2007 everything is fine now. i only restarted apache and refreshed the page. i can see the image clearly now. but i want the image to be placed in an <img> object in html... how can this be done. i dont know how to.. thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/67871-image-imagecopyresized-and-imagecopyresampled-problems/#findComment-341176 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.