python - How to construct a jpeg from a list of grayscale weights -


i'm new @ this, apologies term misuse.

i coding in python. have 2d list contains grayscale values every pixel in image. have modified these values needed , save them new image. how can construct new jpeg array of grayscale values?

i them saved in manner not overwrite original image files, if possible.

i using pil; opened original file image.open('filename') , extracted grayscale values @ each pixel location im.getpixel((i,j)) inside 2 loops.

something should going (not tested):

old_image = image.open("old.jpg") old_data = old_image.load()  new_image = image.new("rgb", old_image.size) new_data = new_image.load()  width, height = old_image.size x in range(width):     y in range(height):         new_data[x, y] = old_data[x, y]   new_image.save("new.jpg") 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -