dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Generating an Image in PHP?

  1. #1
    Join Date
    Apr 2014
    Posts
    18

    Generating an Image in PHP?

    I know it's possible to generate an Image in PHP; However I don't really know how to do it. I found a tutorial explaining it, but I don't want to just have plain text on my Image. I've developed a banner in Photoshop, and I'd like to add some more stylized text on it through a PHP Script.

    Here's my banner that I created in Photoshop.

    http://i61.tinypic.com/nofslt.gif

    I want to change the number of players. This is going to be generated via MYSQL, however an example of just setting it to a pre-defined variable would be lovely.

    IE: $var = 3;

    and then setting the number of players to equal $var

    Anyway, Help. pls.

  2. #2
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    1,843
    imagefttext() allows you to use FreeType 2 fonts.

  3. #3
    Join Date
    Apr 2014
    Posts
    18
    Quote Originally Posted by ShrineDesigns View Post
    imagefttext() allows you to use FreeType 2 fonts.
    How would I go about sending Transparency / Alpha to the font?
    Also, What about my glow effects from Photoshop?

  4. #4
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    1,843
    you can enable transparency via imagealphablending()
    as for applying effects... I don't have much experience applying effects using PHP that you would in a GUI based image editor.
    My best suggestion would be to search the web for PHP based image manipulations.

  5. #5
    Join Date
    Feb 2014
    Location
    Canada
    Posts
    155
    You can use imagecreatefromgif("path/file.gif") to retrieve and return it as an image. If it's an animated gif, then I believe only the first frame will be returned. If it's a custom font you're using or a font not in PHP or the browser, you'll need to load it using imagepsloadfont. To write text, you can either use imagestring, imagepstext or imagegetftext to write text to your image. The difference between these 3 seems to be that imagestring will create a horizontal String but cannot be slanted and you have to position it to be over your image. The latter 2 allow for slant, tightness and other parameters, as well as setting in over the image.

    Writing the number of players can be achieved by storing $val into a $_GET, $_POST or $_SESSION and using it in one of the image-String functions.

    Here's a list of all the built-in PHP image functions.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles