-1

I have a black & white gif from a remote site that changes every day by a script. I want to replace the black part of the image with red. Do you know how to do this in javascript? (No PHP or PNG transparency trick)

The mug example in this tutorial almost works, but I only want to replace the black with red automatically on my server. Maybe a simple tweak there?

How to change color of an image using jquery

Community
  • 1
  • 1
  • `if (currentPixels.data[I] + currentPixels.data[I + 1] + currentPixels.data[I + 2] == 0)` – mmgp Jan 03 '13 at 16:03
  • 1
    I don't think this is possible with older browsers that don't support HTML5. That linked answer explains how to do it with the canvas in HTML5. – jhocking Jan 03 '13 at 16:05
  • possible duplicate of [Creating/modifying images in JavaScript](http://stackoverflow.com/questions/80980/creating-modifying-images-in-javascript) – jbabey Jan 03 '13 at 16:16
  • hello mmgp, you meant to swap this with if(currentPixels.data[I + 3] > 0) // If it's not a transparent pixel right? I tried it and still couldn't get it to work... Any other solutions? Thanks. – cuetable Jan 04 '13 at 19:00

1 Answers1

0

two things:

  1. you should ask the author of the original gif if he allows you to modify it (for copyright reasons)
  2. you should not do it clientsided. for doing it serversided you should use php, nodejs canvas, imagemagic or what so ever.
GottZ
  • 4,824
  • 1
  • 36
  • 46
  • Hi, thanks for the reply 1, I do have the permission 2, It's sort of working as shown in example below. I only need to swapp out the black part of image http://stackoverflow.com/questions/9303757/how-to-change-color-of-an-image-using-jquery – cuetable Jan 04 '13 at 18:54