Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. from PIL import Image
  2.  
  3. import numpy as np
  4.  
  5. file_name = input()
  6.  
  7. orig_color = input()
  8. orig_color1 = tuple(int(orig_color[i:i+2], 16) for i in (0, 2, 4))
  9.  
  10. replacement_color = input()
  11. replacement_color1 = tuple(int(replacement_color[i:i+2], 16) for i in (0, 2, 4))
  12.  
  13.  
  14. img = Image.open(file_name).convert('RGB')
  15. data = np.array(img)
  16. data[(data == orig_color).all(axis = -1)] = replacement_color
  17. img2 = Image.fromarray(data, mode='RGB')
  18. img2.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement