Hi all. I have been waging war with some of the PHP image functions and my God I am so fed up I am about ready to rip my entire head off and kick it into the sun.
Specifically I am writing a script to allow the changing of colors within any given JPEG image, which then resaves the modified image as a new JPEG.
Everything works for the most part, but here is my problem. When I create a new image based off the original, no matter what I do the RGB colors shift.
YES, I am "imagecolorallocate()"ing my RGB colors in the new image. In fact, I am literally doing nothing more than copying the original image. After hours of fighting I went even more simple and look where it got me, nowhere. No matter how little or how much I do, the colors of the new image always shift!!!!!
Here is an example of the index and RGB values for the original image and the copycat image (ya right - it's entirely different).
Original Image
Index(0) = [4, 2, 100]
Index(1) = [52, 102, 204]
Duplicate Image
Index(0) = [4, 10, 108]
Index(1) = [68, 94, 196]
I cannot for the life of me figure out why this is happening. I have tried a number of different methods (3-4 days rotting my brain).
PLEASE! PLEASE! PLEASE!
Anyone out there that can help me with this, please write back. I am so frustrated right now, I'm on the verge of throwing away my entire career as a programmer and flying off to some third world country with polluted water and dedicating the rest of my life to writing viruses that destroy everything they encounter (until I die). And yes, I still want to kick my stupid techie-head into the sun!!!
Oh ya, and here is the little piece of crap that is causing my brain so much stress. Just a few simple lines of code... 😕
=========================
$im_size = GetImageSize ("original_image.jpg");
$imageWidth = $im_size[0];
$imageHeight = $im_size[1];
$im = imageCreate( $imageWidth, $imageHeight );
$darkblue = imagecolorallocate($im, 4, 2, 100);
$lightblue = imagecolorallocate($im, 52, 102, 204);
$im2 = ImageCreateFromJPEG($mod_img);
ImageCopy ($im,$im2,0,0,0,0, $imageWidth, $imageHeight);
ImageDestroy ($im2);
imagejpeg($im, "new_image.jpg", 100);
Is there anyone out that can possibly explain why I am getting this color shift?
EXTREMELY FRUSTATED!!!!
AZ
I now shall await the extreme intellect of the PHPBuilder community. Heck I'll even look forward to hearing someone else gripe about the same problem. Anything folks!! Anything at all.