How to build an image object in PIL/Python

I have a list of 3-item tuples that is the result of list(PIL.Image.getdata()).

How do I do the opposite: build a PIL.Image object from this list?

Answers


The output of getdata() does not include the image format or the size, so you'll need to preserve those (or get the information some other way). Then do this, using the putdata() method:

# get data from old image (as you already did)
data = list(oldimg.getdata())

# create empty new image of appropriate format
newimg = Image.new(format, size)  # e.g. ('RGB', (640, 480))

# insert saved data into the image
newimg.putdata(data)

Need Your Help

How i can solve wi-fi issue in ios6 in iPhone 3gs

iphone ios ios6

when i am testing apps in Real device its communicate with server and fetch data from server but the problem is that wi-fi is going on and off so fetching of data is not properly from server and

Jenkins build fails because can't clone git repo

git jenkins jenkins-plugins

I'm setting up Jenkins for a Rails 3.2 app. I added the Github plugin and setup the keys for the local "jenkins" user on the server. I can git clone from the command line on the server just fine so I

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.