Skip to main content
1 of 6
Swift
  • 133
  • 5

Py3.x - python-imaging-library - Improving a colour conver function

def convert_colour(region_number, incolour, outcolour):
    #print(region_list.regions_d[region_number][0].split('\\')[7], incolour, outcolour)
    img = Image.open(region_list.regions_d[region_number][0])
    img = img.convert("RGBA")
    newData = []
    newData = [outcolour if item==incolour else item for item in img.getdata()]
    img.putdata(newData)
    img.save(region_list.regions_d[region_number][0], "PNG")
    colour_change_single(region_number, outcolour)

I have written the beginning of a map engine which runs off Pil and some javascript client side. Ignoring the rest of the code that is in the same file as this function, can any suggest an imporvement to this code here?

Swift
  • 133
  • 5