daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 60 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. Slow image processing with Python and PIL
  2. from PIL import Image
  3.  
  4. source = Image.open("source.jpg")
  5. colors = source.getcolors(source.size[0] * source.size[1]) #maxcolor value =256, get   all colors with source.size[0] * source.size[1]
  6. pixels = []
  7. for i, color in colors:
  8.     pixels.extend(i * [color])
  9.     pixels.sort()
  10.     new = Image.new('RGB', source.size)
  11.     new.putdata(pixels)
  12.     new.save("new.png")
  13.    
  14. from PIL import Image
  15.  
  16. source = Image.open("source.jpg")
  17. colors = source.getcolors(source.size[0] * source.size[1]) #maxcolor value =256, get   all colors with source.size[0] * source.size[1]
  18. pixels = []
  19. for i, color in colors:
  20.     pixels.extend(i * [color])
  21. pixels.sort()
  22. new = Image.new('RGB', source.size)
  23. new.putdata(pixels)
  24. new.save("new.png")
  25.    
  26. colors = source.getcolors(source.size[0] * source.size[1])
  27. colors.sort(key=lambda pair: pair[1])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top