views:

43

answers:

1

I need to access 3 values of color that are contained in my theme's currently active skin folder. In each of my theme's "skin" folder's I have 3 images: header.gif, footer.gif and spot.gif.

These images are all the same size and are just used for background colors in my theme skins. The theme owner can create a custom color for each of their theme skins and these are stored in the respective skin's folder.

Can someone help me with the code to do this?

The way I see it, I can either open the files themeselves then read the RGB value and assign that to a variable I can use, or I can open a text file containing the values (written at the same time I recolor the images when theme options are saved)

If I use a text file, I will store the values in a file called colors.txt like so...

color1=000000,color2=123456,color3=cccccc

This is off the top of my head. Perhaps an xml format might be better, I'll leave that up to discussion. Its just a small data store.

At run time, I simply want to retrieve this file and grab the value of each color and then assign that to my colorpicker thumbnail to show the current custom spot colors for the user's chosen skin for my theme.

These colors represent the color of each of 3 images in each of my theme's skins folders (header.gif, sidebar.gif and spot.gif). If its easier just to open those files and read the color value then convert it to hex, I'd rather do that.

I hope I've explained it well enough :)

A: 

Your gifs are a single uniform color each? Can't you use CSS for background colors in that case?

Offhand I would say it would be much easier to store your color values as JSON or XML and read it that way; this will save your script the overhead of opening an image and getting data every time you run it.

However, if you feel the need to get colors from images, or you need to calculate the average color in an image (or something) have a look at the GD image manipulation library, if I understand you correctly you could use imagecolorat and imagecolorsforindex to get RGB values from your images.

Loyal Tingley