Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5

Thread: PHP GD question

  1. #1
    Senior Member straight_up's Avatar
    Join Date
    Dec 2003
    Location
    Pennsylvania/Arizona
    Posts
    601
    Member #
    4309
    I am totally new to PHP's GD functions (image editing).

    But i know what I want to do:
    Take one image, or three, it doesn't matter, and resize either the second image or the middle part of the one image, over which some Arial text will be laid. Output as PNG or GIF.

    How can I either add onto an image two "side" images or resize part of one image?

    Thanks in advance!

    And relatedly, how can I tell how much room I'll need for a custom string (in a non-fixed-width font like Arial)?
    I am Alan Hogan (@alanhogan on Twitter). I like PHP, UI/UX design, and OS X.

  2.  

  3. #2
    Senior Member straight_up's Avatar
    Join Date
    Dec 2003
    Location
    Pennsylvania/Arizona
    Posts
    601
    Member #
    4309
    Nevermind. I got it to work, looking around and learning from php.net and a couple of scripts some people had posted online.

    My script is, however, original AFAIK. (I'm sure someone, though, must have done this before.)

    Anyway, it takes 3 images, text, a font, font color, and a couple other variables like whether text should be made all uppercase or all lowercase, padding, etc., and creates a custom, beatiful PNG button. The middle image is scaled so the button is always a perfect fit for the text. It will soon cache them -- i just now finished the basic script.

    Feel free to play around here (not linked so no robots will hammer it; change those two spaces into dots):
    www pixelsandpages com/images/magic/button-maker-demo.php?text=Hey,+WDF

    Cool, huh? :-)

    If you want the code, talk to me. I don't know if I'll charge or not.
    I am Alan Hogan (@alanhogan on Twitter). I like PHP, UI/UX design, and OS X.

  4. #3
    Senior Member Shani's Avatar
    Join Date
    Nov 2004
    Posts
    1,140
    Member #
    8171
    That's pretty cool. I assume everything is lower case and every + gives a space. Did you try limiting the number of characters or reducing the text size if someone like me decided to play around with a very large string?
    Shani

    I have an eye for detail like you'd never believe.

  5. #4
    Senior Member straight_up's Avatar
    Join Date
    Dec 2003
    Location
    Pennsylvania/Arizona
    Posts
    601
    Member #
    4309
    I gave it an option to turn everything into lowercase; you tested it with that option "on" (I have since been messing with it).

    As far as limiting the number of characters... actually, no. Though I did deal with *short* strings (zero, or so small the middle image would have a negative size). THanks for the tip (Currently a longggggg string just makes it a wiiiiide image. which is mostly ok, i guess i should set a reasonable limit like 512 characters or something.
    I am Alan Hogan (@alanhogan on Twitter). I like PHP, UI/UX design, and OS X.

  6. #5
    Senior Member straight_up's Avatar
    Join Date
    Dec 2003
    Location
    Pennsylvania/Arizona
    Posts
    601
    Member #
    4309
    I don't think i mentioned this: you can upload any font and use it... which can give some pretty cool effects you simply can't acheive using just HTML output.
    I am Alan Hogan (@alanhogan on Twitter). I like PHP, UI/UX design, and OS X.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:47 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com