[Image-SIG] true colors in gd

Necati DEMiR ndemir at demir.web.tr
Sun Mar 13 05:23:32 CET 2005


Hello,
how can i use true colors by using gd library.
for example, the following code must copy the image but it doesn't

#!/usr/bin/python

import gd
inp = gd.image("input.jpg")
gd.gdMaxColors = 256
print inp.getClip()[1][0]+1,inp.getClip()[1][1]+1
output = gd.image((inp.getClip()[1][0]+1,inp.getClip()[1][1]+1))

for i in range(0, inp.getClip()[1][0]+1):
    for j in range(0, inp.getClip()[1][1]+1):
        red = inp.red(inp.getPixel((i,j)))
        green = inp.green(inp.getPixel((i,j)))
        blue = inp.blue(inp.getPixel((i,j)))
        color = output.colorAllocate((red, green, blue))
        output.setPixel((i,j),color)

f=open("out.png","w")
output.writePng(f)
f.close()

-- 
------------------------------------------------
Necati DEMiR
ndemir at demir.web.tr
http://demir.web.tr
My Public Key => http://demir.web.tr/ndemir.asc
-------------------------------------------------



More information about the Image-SIG mailing list