473,748 Members | 4,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2286
"avlee" <xx@wp.plwrot e in message news:op.togbw2t k1sq83a@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 = imagecreatetrue color(400, 30);

// Create some colors
$white = imagecoloralloc ate($im, 255, 255, 255);
$grey = imagecoloralloc ate($im, 128, 128, 128);
$black = imagecoloralloc ate($im, 0, 0, 0);
imagefilledrect angle($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($i m, 20, 0, 11, 21, $grey, $font, $text);

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

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

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi. net | rot13(xv***@bhg byrzcv.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 = imagecreatetrue color(400, 30);

// Create some colors
$white = imagecoloralloc ate($im, 255, 255, 255);
$grey = imagecoloralloc ate($im, 128, 128, 128);
$black = imagecoloralloc ate($im, 0, 0, 0);
imagefilledrect angle($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($i m, 20, 0, 11, 21, $grey, $font, $text);

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

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($i m);
?>
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="myimagescr ipt.php?whateve r=parameters"/>

<p>More text</p>

</BODY>
</HTML>
On Feb 28, 11:22 am, avlee <x...@wp.plwrot e:
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 = imagecreatetrue color(400, 30);
// Create some colors
$white = imagecoloralloc ate($im, 255, 255, 255);
$grey = imagecoloralloc ate($im, 128, 128, 128);
$black = imagecoloralloc ate($im, 0, 0, 0);
imagefilledrect angle($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($i m, 20, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($i m, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($i m);
?>

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********@gmai l.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="myimagescr ipt.php?whateve r=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********@gmai l.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="myimagescr ipt.php?whateve r=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
1471
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) System.InvalidOperationExceptionSystem.InvalidOperationException: The object is currently in use elsewhere. at System.Drawing.Image.get_Width() at System.Drawing.Image.get_Size() at System.Windows.Forms.PictureBox.GetPreferredSize() at...
0
2627
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 image has 4 transparent pixels; the upper left, upper right, lower left & lower right. This is to help give the otherwise square button graphic a slightly rounded look to it.
2
7236
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 with the posted file, I get an error saying file type HttpPostedFile cannot be converted to an Image. When I save the original and try and use the FromFile method to create the thumbnail, it says that the file is already in use. Any ideas?
3
1777
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>")> Public Class WebCustomControl5 Inherits System.Web.UI.WebControls.WebControl Dim _text As String
13
3343
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 referenced, custom dll. I call a PrintImage routine in the dll and pass it only the the Picturebox.hdc from the main form. The dll's print routine draws to the hdc and it shows up in the picturebox perfectly. I would like to do a similar thing...
1
1332
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 text. Is this possible? I'm guessing I can get the height from the Font.Height property. But how do I go about getting the width of the drawn text? Also, are there any tip for drawing fairly smooth fonts?
9
3181
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 want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
3
6442
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 imagebuttons which point to a dummy page that takes the image and displays it via response. All works fine if I use explicit paths to a file (response.writefile(<filename>) or directly pass through the database image...
2
2329
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 response object but how do I write it to screen? Dim objBitmap As New System.Drawing.Bitmap(400, 440) Dim objGraphics As System.Drawing.Graphics objGraphics = System.Drawing.Graphics.FromImage(objBitmap) objGraphics.Clear(Drawing.Color.White)
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.