473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

drawing images and text

Hello

i have a code:
/* some code creating picture */
header("Content-type: image/jpeg");
imagepng($new);

it draws my picture correctly.

But what to do when i want to draw a picture on my page - with other text
data ?
When i tried to:
header("Content-type: image/jpeg");
echo "Some text"
imagepng($new);

my web browser received "Some text <image code" and did not know how to
display it.

How can i fix it and display drawed image along with other things on my
page ?
Thanx
Feb 28 '07 #1
5 2260
"avlee" <xx@wp.plwrote in message news:op.togbw2tk1sq83a@saturn...
Hello

i have a code:
/* some code creating picture */
header("Content-type: image/jpeg");
imagepng($new);

it draws my picture correctly.

But what to do when i want to draw a picture on my page - with other text
data ?
When i tried to:
header("Content-type: image/jpeg");
echo "Some text"
imagepng($new);

my web browser received "Some text <image code" and did not know how to
display it.

How can i fix it and display drawed image along with other things on my
page ?
http://fi.php.net/manual/en/function.imagettftext.php
On the manual page there is an example:

<?php
// Set the content-type
header("Content-type: image/png");

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Feb 28 '07 #2
Hello
>How can i fix it and display drawed image along with other things on my
page ?

http://fi.php.net/manual/en/function.imagettftext.php
On the manual page there is an example:

<?php
// Set the content-type
header("Content-type: image/png");

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
I do not want to display text ON the image. I want to display text
after/before the image.
I want to display that image on my corporate page with hundreds of other
images/text/html/frames/flash....
Is it possible ?

(i want to aviod creating of temporary files for my dynamically generated
images)

Thanx
Feb 28 '07 #3
I may be wrong (not played with GD for quite a while), but I *think*
you just use a normal HTML <imgtag in the page to reference the
script which draws the image. So:

<HTML>
<BODY>
<p>Some text</p>
<img src="myimagescript.php?whatever=parameters"/>

<p>More text</p>

</BODY>
</HTML>
On Feb 28, 11:22 am, avlee <x...@wp.plwrote:
Hello
How can i fix it and display drawed image along with other things on my
page ?
http://fi.php.net/manual/en/function.imagettftext.php
On the manual page there is an example:
<?php
// Set the content-type
header("Content-type: image/png");
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

I do not want to display text ON the image. I want to display text
after/before the image.
I want to display that image on my corporate page with hundreds of other
images/text/html/frames/flash....
Is it possible ?

(i want to aviod creating of temporary files for my dynamically generated
images)

Thanx

Feb 28 '07 #4
cs********@gmail.com wrote:
I may be wrong (not played with GD for quite a while), but I *think*
you just use a normal HTML <imgtag in the page to reference the
script which draws the image.
<img src="myimagescript.php?whatever=parameters"/>
Correct. Use two PHP pages, one producing HTML and one producing JPEG
(or PNG, for that matter). The HTML page can reference the image (which
was produced by PHP) as if it was a normal image.
Feb 28 '07 #5

cs********@gmail.com wrote:
>I may be wrong (not played with GD for quite a while), but I *think*
you just use a normal HTML <imgtag in the page to reference the
script which draws the image.
><img src="myimagescript.php?whatever=parameters"/>
Thanx a lot:)
Feb 28 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: zengou | last post by:
My application have many picturebox objects,when run it ,sometimes i will have a strange error,how to work out ,help me please!(in windows98,the error cause frequently than in windowsxp) ...
0
by: eruess | last post by:
Here's the scenario: I've got a whole bunch (for the sake of argument, let's say thousands) of different little 32x14 .png files that act as buttons all over a very large website. Each button...
2
by: NATO24 | last post by:
Hello, I am trying to write a sub routine that I can pass a posted (image) file to. That routine will save the original file, then create a thumbnail and save it. When I try to create the image...
3
by: Qwert | last post by:
Heya, I have a cusom control: Imports System.ComponentModel Imports System.Web.UI <DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl5 runat=server></{0}:WebCustomControl5>")>...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
1
by: jjbutera | last post by:
There are a lot of examples out there, but I was hoping something could help me further. I'd like to draw text (unknown length) to an image, but then crop the image to the height and width of the...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
3
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating...
2
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.