Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 334609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:04:15+00:00 2026-05-12T10:04:15+00:00

I have a Ubuntu server and PHP5, and the PHP script files, and all

  • 0

I have a Ubuntu server and PHP5, and the PHP script files, and all output are in UTF-8.
I’m trying to send an image to the output stream, but just garbled chinese characters shows up in the output:

$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);

any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:04:16+00:00Added an answer on May 12, 2026 at 10:04 am

    Your code works perfectly fine on my machine :

    <?php
    $im = imagecreatetruecolor(120, 20);
    $text_color = imagecolorallocate($im, 233, 14, 91);
    imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
    header('Content-type: image/jpeg');
    imagejpeg($im);
    imagedestroy($im);
    
    die;
    ?>
    

    Are you sure you are not outputing anything before or after that code ? Even any kind of whitespace would be a source of troubles.

    Or maybe your script is doing something else somewhere ?

    If it still doesn’t work, maybe trying with imagettftext, to use a “better” / more complete font than the ones used by imagestring might help ?

    Using something like this, for instance :

    $font = '/usr/share/fonts/truetype/msttcorefonts/arial.ttf';
    imagettftext($im, 20, 0, 10, 20, $text_color, $font, 'A Simple éléphant String');
    

    BTW, did you try without those line :

    header('Content-type: image/jpeg');
    imagejpeg($im);
    imagedestroy($im);
    

    If there is an error/warning/notice, removing those lines might help you seeing those.

    And, as a sidenote : using JPEG for images that contain some text generally doesn’t give great results, as JPEG is a destructive compression mechanism. Using PNG, in that kind of situation, might get you better results 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 227k
  • Answers 227k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this: public class MyModel { Expression<Action<MyController>> Action { get;… May 13, 2026 at 1:27 am
  • Editorial Team
    Editorial Team added an answer EDIT - Here's a new function that includes staying at… May 13, 2026 at 1:27 am
  • Editorial Team
    Editorial Team added an answer This should do it: $digest = hash_hmac("sha1", $hash_string, base64_decode($key), true);… May 13, 2026 at 1:27 am

Related Questions

I'm trying to port a PHP site developed by another coder (who is no
I have django+python+apache2+mod_python installed hosted and working on ubuntu server/ linode VPS. php5 is
I am trying to implement a password reset functionality on my company website where
I have been using Apache on my local LAN. The problem is that i

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.