New version of rgba.php is out!

Reading Time: 2 minutes

It’s been a while since I posted my little server-side solution for cross-browser RGBA colors (in a nutshell: native rgba for the cool browsers that support it, a PHP-generated image for those that don’t). For features, advantages, disadvantages etc, go see the original post. In this one I’ll only discuss the new version.

So, since it’s release I’ve received suggestions from many people regarding this script. Some other ideas were gathered during troubleshooting issues that some others faced while trying to use it. I hope I didn’t forget anything/anyone 🙂

Changelog (+credits):

  1. You may now specify the size of the generated image (thanks Sander Arts!)
  2. If the PHP version is below 5.1.7 the call to imagepng() uses 2 parameters instead of 4, to workaround the bug found by Bridget (thanks Chris Neale for suggesting the use of phpversion()!)
  3. Added error_reporting() to only allow for fatal errors and parse errors to go through (I should had done this anyway but I completely forgot). This solves an issue that Erin Doak pointed out, since they had set up notices to be displayed and even a reference to an undefined index made the whole script collapse.
  4. Mariotti Raffaele pointed out that apache_request_headers() was not defined in all PHP installations. After looking into it a bit, I found out that it’s available only when PHP is installed as an Apache module. After some more research it turned out that the only way to get the If-Modified-Since header otherwise is an .htaccess, so I  ruled that out (It would complicate the workaround I think and I doubt all hosts allow .htaccess (?). On the other hand, an .htacess would also allow for some URL rewriting goodness… Hmmm… Should I consider this?). So, if the function is not available, it serves the file with an 200 response code every time, instead of just sending a 304 response when the If-Modified-Since header is present.
  5. Igor Zevaka for pointing out that the Expires header wasn’t a valid HTTP date.




Enjoy 🙂 and please report any bugs!

49 replies on “New version of rgba.php is out!”

Oh lea, u drive me crazy! That is a greate tool and to say the truth, i have missed it when u first posted it.

Combining it with a good UI, it can be easilly used for option templates to WordPress (sorry, but i am wp addicted :P)

Thanks, Lea! I was having trouble with the old script (it would break after initially loading… I think related to undefined apache_request_headers() as you pointed out). This cleared everything up. RGBA in IE the easy way… makes me very happy!

Thanks for this!

Also, why don’t you allow for urls like this?: rgba.php?1,2,3,4

I don’t think these would have to be urlencoded, and it would be easier to read.

Only thing about this that i find slightly confusing.. is that say you use

background: url(rgba.php?color_r=46&g=46&b=50&a=30) repeat;
background: rgba(46,46,50, 0.3);

They end up being 2 totally different colours.. so its hard to get the right combination to keep the same colours using the 2 methods..

Yeah, the color_ part was unnecessary and you ended up not specifying r this way.

By the way, one feature I’d like to implement in the next version is making the syntax more similar to the CSS one, like rgba.php/rgba(46,46,50,0.3) instead of rgba.php?r=46&g=46&b=50&a=30

مه پاش

Hello would you brain stating which site platform you’re working with? I’m organizing to begin my very own site quickly but I’m having a difficult time choosing among BlogEngine/Wordpress/B2evolution and Drupal. The cause I question is because your des…