472,789 Members | 956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Font color in jpeg image (nearly) always orange

I am trying to run a basic script that displays an existing jpeg image
and writes some text over it. Sounds simple, but I cannot seem to be
able to colour the font correctly. In the example below it should be
black but it comes out orange. In fact, even if I change the colour to
0, 0, 255 it's orange.

I've read in the PHP documentation (the user contributed notes) that
there are issues with jpeg font colouring. But I've not seen any
details. Can anyone shed light on this for me please?

The example code below is called as a function. The $image variable is
a path to the existing image file and the $ttf variable is a path to a
TrueType font. The $text variable contains a text string.

header("Content-type: image/jpeg");
$base_image = imagecreatefromjpeg($image);
$font = $ttf;
$fontcolor = imagecolorallocate($base_image, 0, 0, 0);
imagettftext($base_image, 18, 0, 10, 100, $fontcolor, $font, $text);
imagejpeg($base_image); imagedestroy($base_image);

Cheers,
Si.

Oct 11 '06 #1
1 1917

sp********@gmail.com wrote:
I am trying to run a basic script that displays an existing jpeg image
and writes some text over it. Sounds simple, but I cannot seem to be
able to colour the font correctly. In the example below it should be
black but it comes out orange. In fact, even if I change the colour to
0, 0, 255 it's orange.

I've read in the PHP documentation (the user contributed notes) that
there are issues with jpeg font colouring. But I've not seen any
details. Can anyone shed light on this for me please?

The example code below is called as a function. The $image variable is
a path to the existing image file and the $ttf variable is a path to a
TrueType font. The $text variable contains a text string.

header("Content-type: image/jpeg");
$base_image = imagecreatefromjpeg($image);
$font = $ttf;
$fontcolor = imagecolorallocate($base_image, 0, 0, 0);
imagettftext($base_image, 18, 0, 10, 100, $fontcolor, $font, $text);
imagejpeg($base_image); imagedestroy($base_image);

Cheers,
Si.
In case anyone with similar problems reads this thread I should point
out that I now believe the failure of the above script to be due to a
bug in an earlier-than-current version of PHP/GD. I am using PHP 4.4,
GD 2.0.26.

It seems that I'm not the only one to get a yellow/orange font (or
nothing, depending on what you set the font colour to) when using
imagettftext and imagecreatefromjpeg (or imagecreatetruecolor). I've
done a work-around involving merging images, but it's not perfect. I
guess the real answer is to upgrade.

Cheers,
Si.

Oct 12 '06 #2

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

Similar topics

1
by: Fabian Rossbacher | last post by:
hello, does anybody know how to change font-face in Arial,Verdana etc. when i'm using image-functions of PHP? Font-Size is clear to me... $fontSize=2 imagestring($im, $fontSize, $px,...
131
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately...
25
by: Neal | last post by:
According to the CSS lint at http://htmlhelp.org/tools/csscheck/, "The shorthand background property is more widely supported than background-color." Can anyone point me to, or provide, information...
2
by: ZUP_DUDE | last post by:
Hi All, I'm using the System.Drawing.Image name space to convert images from one type to another. In this case I am trying to convert a Tiff to a JPEG. The code is as simple as the next two...
5
by: localhost | last post by:
I have a custom TrueType .ttf font in the filesystem (not installed) on the web server. I want to take the letter "A" from this font, render it as an image, and return that as a byte stream in...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
6
by: ryan.mclean | last post by:
Hi all! I was hoping someone could help me out. What I would like to do is use a font that is not installed on the server, but does reside in my local web. Does that make sense? I would like to...
1
by: Joe Cool | last post by:
I am attempting to add a function to an application I am working on to modify the JPEG Comment in a Jpeg image file. I can retrieve the JPEG Comment with no problem. The problem is modifying it....
3
by: J(ohn|ane) Doe | last post by:
I have many webpages with thumbnail pictures. Each thumbnail is a hyperlink to a large picture. The HTML code is similar to this: Now this worked okay on my old server. I got a new webhost,...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.