Solved

PHP Fade

Posted on 2012-04-02
5
240 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 109

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 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