Reply to Re: Mixing Php's imagecopy and HTML

Your name:

Reply:


Posted by d on 01/25/06 13:45

"Ubantu Rococo" <paul.x.lee@baesystems.com> wrote in message
news:43d76123$1_1@glkas0286.greenlnk.net...
> Hi all,
> Sorry for this stupid question, but I am having trouble mixing imagecopy
> etc. with HTML.
> What I am trying to do is copy an image, and then obtain co-ordinates from
> a database which will then be drawn
> on the image (to create a clickable imagemap). The image will then be
> displayed as part of a webpage.
>
> I've included my code snippet below. It doesn't work, and I think I know
> why - the output on my screen
> grumbles about the header information already being sent. Is there any way
> to do what I want it do?
> Perhaps putting the image copy calls in a separate function call?
>
> Sorry for the stupid question, I am new to php.
>
> Best wishes
>
> Paul
>
>
>
> <HTML>
>
> <H1>Test...</H1>
>
> <?php
>
> // File and new size
>
> $filename = 'logo_i.JPG';
>
> // Content type
>
> header('Content-type: image/jpeg');
>
> // Get new sizes
>
> list($width, $height) = getimagesize($filename);
>
> // Load
>
> $thumb = imagecreatetruecolor($width, $height);
>
> $source = imagecreatefromjpeg($filename);
>
> // Resize
>
> imagecopy($thumb, $source, 0, 0, 0, 0, $width, $height);
>
> imagerectangle($thumb, 10,10,50,50,4500);
>
> // Output
>
> imagejpeg($thumb);
>
> ?>
>
> </HTML>
>
>

I don't think imagejpeg works as you think it does. It outputs an image's
actual binary data, so you're essentially trying to output a jpeg image with
HTML tags before and after it - which won't work. What you need to do, is
put the PHP code only into a file, called say image.php. Then, in your HTML
document (the rest of the code above), just put an image tag in: <img
src="image.php">. That will display the image in the HTML page. You can
even have javascript to work out where you click on the image, and then
update its url like this:

<img src="image.php?x=10&y=22">, and the image.php can then add something at
those co-ordinates to demonstrate it has been selected.

dave

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация