PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Nov 16, 2018 8:28 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Sep 10, 2007 2:29 am 
Offline
Forum Newbie

Joined: Mon Sep 10, 2007 2:26 am
Posts: 2
I was hoping to someone could help me find a way to simulate the 'Color Overlay' feature from Photoshop using only the GD Library...

Basically I have a transparent overlay that I want to place over a background image...
This is so I can fade the edges of that image to the background color of the page...
This I've already done...

However the overlay image is a set color, black in this case...
I need to be able to change it under certain circumstances to match the page color...

To change this in Photoshop I would just go to blending options -> color overlay and select a different color...

I was hoping to find a way of doing this using the GD Library instead...

The overlay picture can be found here... http://trekcon.com/overlay/overlay.png
The background picture can be found here... http://trekcon.com/overlay/background.jpg
The result can be found here... http://trekcon.com/overlay/composite.jpg
The code can be found here... http://trekcon.com/overlay/watermark.php

Hopefully what I'm asking makes sense :)

Thanks in advance for any help
Jason Hart (aka Runey)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2007 3:09 am 
Offline
Forum Newbie

Joined: Mon Sep 10, 2007 2:26 am
Posts: 2
feyd | Please use
Syntax: [ Download ] [ Hide ]
,
[syntax=php]and
Syntax: [ Download ] [ Hide ]
  1. tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too. 
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Well it's always the way... I spent the last couple of days trying to figure this out... 
  8.  
  9. So of course no sooner after I post this plee for help, do I figure it out for myself... 
  10.  
  11.  
  12.  
  13. The above links are still valid (for now)... 
  14.  
  15.  
  16.  
  17. Here's the code I came up with... I would still appreciate knowing if there is a better way of doing this... 
  18.  
  19.  
  20.  
  21. Thanks... 
Syntax: [ Download ] [ Hide ]
<?php

// Runey (2007)

// trekcon@gmail.com



// Variables to be passed by community builder

$overlay = 'overlay.png';

$background = 'background.jpg';

$color = '000000';



// Open overlay and background images

$overlay = imagecreatefrompng($overlay);

$background = imagecreatefromjpeg($background);



// Turn on Alpha Blending

imagealphablending($background, true);



// Colorize overlay image

imagefilter($overlay, IMG_FILTER_COLORIZE, hexdec('0x' . $color{0} . $color{1}), hexdec('0x' . $color{2} . $color{3}), hexdec('0x' . $color{4} . $color{5}));



// Place colorized overlay on background image

imagecopy($background, $overlay, 0, 0, 0, 0, imagesx($overlay), imagesy($overlay));



// Output header and final image

header("Content-type: image/jpeg");

header("Content-Disposition: filename=" . $background);

imagejpeg($background, NULL, 80);



// Destroy image data

imagedestroy($overlay);

imagedestroy($background);



?>



feyd | Please use
Syntax: [ Download ] [ Hide ]
,
[syntax=php]and
Syntax: [ Download ] [ Hide ]
  1. tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too. 


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2007 7:40 am 
Offline
DevNet Master
User avatar

Joined: Sun Jan 21, 2007 12:06 am
Posts: 4135
A *better* way? I doubt that there's a faster way then simply putting a transparent layer over it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group