Results 1 to 4 of 4

Thread: php images and transparency

  1. #1
    Join Date
    May 2006
    Location
    New York City
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php images and transparency

    I am so confused by php images when it comes to transparency . . .

    I tried to put a border around a jpg by merging it with a png that had a transparent center, but every time I merge the images, the center of the png comes out matted black. The same thing happens when I use a gif.

    I tried to use the imagecolortransparent() function, but it keeps giving me an error. The documentation for this function on php.net is very confusing to me and every other documentation I've seen has simply been a mimic of php.net.

    Does anybody know how to use this function? Or at least, to get around using it?

    I'm working on php4.4.3, btw.

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    From what I understand about the function is that only one color can be transparent.

    So say you choose black, when you add that image to the function anything in that image that is black will then become transparent.

    If you want the background to be transparent you have to call 2 colors, the first acting as a dummy color, to which the function will then use the second color as the transparency color (your background)

    Why can't you just take the single image and use photoshop or similar to make your transparency/opacity the way you want and just use that?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm playing with the GD library myself, at the moment.

    However, I haven't tried that function, no.

    Graphics work from text commands is a pain. I'm tired... been working with it too long tonight.

    If I were you, I'd be looking for another more logical solution, not to say that won't work, just that something else might make more sense. I may take a look when my brain isn't already burned out.

    However, what Blizzard said sounds promising, so do try that.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    May 2006
    Location
    New York City
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It seems logical that one should allocate a color and then set it to transparent and that that should work, but for some reason it doesn't. For some reason, regardless of what color I allocate, the transparency comes out as the matte color, and when use an image with no matte, the transperancy comes out black.

    I would just edit all my images in photoshop, but then i'd need to have two images for each image: one with a border and one without it, and this could become a hassle in the future when i'm adding new images.

    Has anybody used this function successfully?

Bookmarks

Posting Permissions

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