Solved

PHP Fade

Posted on 2012-04-02
5
239 Views
Last Modified: 2012-04-18
Im looking at a way of creating an image which fades. I know I can use jQuery to create a fade, but Id like to do it in php so I can create shapes with fades.

So my question is, can I produce a rectangle, with a fill fading from one colour to another?

Also is it possible to create a circle, with a filling of transparent?

Thank you
0
Comment
Question by:tonelm54
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37798386
Since all PHP processing is done on the server before the page gets to the browser, I don't see how PHP can help you with this.  You could possibly use AJAX to get each change from a PHP page but that is a lot of network activity accessing the server for each item.
0
 

Author Comment

by:tonelm54
ID: 37798427
Sorry, maybe some confusion, the image I'd like to be static (doesn't change after generated).

I have a template of a site which is yellow, which fades out to white or transparent (depends on the image), what I'm trying to do is create a script that will generate the image for me, so I can pass it the yellow parameter to draw the image fading to transparent, or I can pass it blue and it generates an image fading from blue to transparent.

I know it might be easier to create all the possible images, but doing it in code means I can quickly make it a shade darker or lighter without much effort.

Thank you
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37798452
I think thats normally called a 'gradient' where it blends from one color to another.  Note that PNG and GIF support transparency but JPEG does not.  Here's a page that talks about it: http://www.bradshawenterprises.com/blog/2010/dynamically-drawing-gradients-with-php/
0
 
LVL 7

Accepted Solution

by:
designatedinitializer earned 500 total points
ID: 37798464
What you need is usually called a "gradient".
Check out this class, as it does exactly what you are trying to do:
http://planetozh.com/blog/my-projects/images-php-gd-gradient-fill/
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37798935
If what you're looking for is a gradient, it looks something like this.Gradient from Red to White VerticallyAnd you would be doing everyone a favor if you create static images one pixel wide (or high, depending on the direction of the gradient).  Use CSS to repeat the image across the gradient area.  Generating a gradient on the server for every request is like putting new tires on your car every time you want to take a drive.  Sure, you can do it -- it just doesn't make sense in the real world.

If what you want is a fading effect like what happens to the captions on the banner images (onMouseOut) here, you can use jQuery.  Just use view source and copy my code.
http://www.landonbaseball.com/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now