Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Generating Images in Japanese >.<

    I'm REALLY confused with generating images using GD. I have the font, size for font, font color, color background, image size, etc, but I have no idea how to put it together. I want to make a transparent image 200x30 pixels large that has a word in Japanese (picked from a database) in the center of it using msgothic.ttc as the font and font size 24 in black.

    I've seen many examples but I'm just utterly confused. I tried to put things together, but I always get like a dozen errors if I don't use the exact code of examples. And that's pretty much useless. So can anyone show me how to do this?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Image creation is always complicated in any language. Rather than walk you through it which will likely be more confusing for you, I would suggest trying things one by one.
    Start with a simple image, 200x30 and change its background colours. Once you can do that, you have the base.
    After that, work on adding the text for the image. Text is IMO the most difficult thing to do with the GD libraries, alignments are a pain and wrapping doesn't exist so you need to do calculations. A single character will be fine. This assumes you have access to msgothic or have uploaded the file and that the character you require exists within the set.

    The function(s) you will need are:
    imagecreate / imagecreatetruecolor
    imagecolorallocate
    imagettftext
    imagettfbox
    image* (imagepng, imagejpg, etc for actual output)
    imagedestroy
    header

    As I mentioned, the most difficult part will be the alignment of the graphic, and the existence of it. I don't know what fontset you'll need to use that has the glyph in it you require.

    Try using these, come back with specific problems.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    Eugeniu (07-17-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •