Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 29th, 2005, 04:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This seems wrong to me. You can't output an HTTP header once you've already started outputting HTML text.

In your code, you have:
Quote:
quote:Originally posted by cli

Code:
<html>
    <head>
    </head>
<body>
    <table width="100%"  border="1" cellspacing="0" cellpadding="0">
        <tr>
            <td>
<?php
        $mydir = "uploaded_image_visual";
        $mynameimage = "sezioni_capelli.jpg"; 
        $myimage = $mydir."/".$mynameimage ;

     $mainImage = imagecreatefromjpeg($myimage);   
     $mainWidth = imagesx($mainImage);
     $mainHeight = imagesy($mainImage);
     $thumbWidth = intval($mainWidth / 4);
     $thumbHeight = intval($mainHeight / 4);
$myThumbnail = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($myThumbnail, $mainImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $mainWidth, $mainHeight);
header("Content-type: image/jpeg");
imagejpeg($myThumbnail);
imagedestroy($myThumbnail);
imagedestroy($mainImage);

?>
</td>
</tr>
</table>
</body>
</html>

If you're going to output an image, you need to have an <img> tag with a filename/path to the image file. Now, this filename can be a PHP file, as long as the PHP script outputs the proper header for the image Content-type and spits out the binary image data.

If you already have the image files on your machine, perhaps you should write a generic resizer script that accepts the filename as a GET parameter and resizes whatever filename you pass in.

Make sense?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete a record row, not just the record. Coby Access VBA 1 April 30th, 2007 06:29 AM
how to add new record as first record in dataset [email protected] ASP.NET 1.0 and 1.1 Professional 4 April 21st, 2006 05:23 AM
Record locking - user needs the next queued record cbtoolkit SQL Server 2000 0 December 6th, 2004 08:29 AM
Empty record field, No image dstubblefield Dreamweaver (all versions) 6 September 3rd, 2004 01:05 AM
Sub record not associating with Main record Ron V Access 1 August 31st, 2004 09:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.