hello guys. i dont get any image when the following code is run.. i dont know. but i copied them from the php manual itself. is something wrong with my gd library? <?php // The file you are resizing $file = 'http://localhost/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); ?> Code (markup): 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); ?> Code (markup): pls i need help
Try: $filename = 'D:\\public\\try.jpg'; PHP: If that doesn't work either, use your browser's "view page source" and see if you get any PHP errors. Oh, and please use wrappers instead of [code] wrappers when posting PHP code. PHP:
hello guys. everything works perfectly now guys. i can now see the image displayed. but i want the image to be placed in an <img> object in html... how can this be done. i just dont know how to do this. thanks a lot.
Save the code above as "image.php" or similar, and embed it into your HTML like it was a normal image. <img src="image.php" /> HTML:
really? thanks a lot... but wont this kind of keep these in memory? is there a delete something and how?