Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'read.': 0.03; 'explicitly': 0.05; 'pil': 0.09; 'cc:addr:python-list': 0.11; '24]': 0.16; 'files:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'helps!': 0.16; 'ioerror:': 0.16; 'ought': 0.16; 'oyster': 0.16; 'png': 0.16; 'problem!': 0.16; 'do,': 0.16; 'wrote:': 0.18; '(not': 0.18; 'trying': 0.19; 'help.': 0.21; 'memory': 0.22; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'load': 0.23; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'url:code': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'img': 0.31; 'them?': 0.31; 'file': 0.32; 'open': 0.33; 'url:python': 0.33; 'url:source': 0.33; 'knowledge': 0.35; 'objects': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'too': 0.37; 'list': 0.37; 'being': 0.38; 'work?': 0.38; 'files': 0.38; 'does': 0.39; 'according': 0.40; 'url:mail': 0.40; 'how': 0.40; 'hope': 0.61; "you're": 0.61; 'url:p': 0.64; 'more': 0.64; 'abandon': 0.84; 'abandoning': 0.84; 'glance': 0.84; 'subject:+ ': 0.84; 'pic': 0.91; 'to:none': 0.92; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=aY49DNL8vlYjCU8KC0yFpGbEGBLO57YazjWqLgLRmp8=; b=uKyuooYm6HgFHb3+NScsl8H5950dJdiiuxXwLpOKTcZNwrOH3dPqegNYnp5CeSlCen vnLZw7XGX6vYH0SSFrO8yVCC4KPYqIKCa6e/ZTErChNCyqTatttHGBwjN1y+yvtgBW5Z SwbMAEoBMsH4hXiAkeGYe2YWlogmQ44mhc5nlbSX262ta/26LfDb0EX3CGYVhHoi6Yrr cKTMP3q9Xt/ls4rfsaKQ1Mc3oygaVB+BoBA18gpKnZLn34U6uPuT4lE8twwXwBLh1OFZ Ltf0Beltq1uwkW4Cl3ES1rzfG3WbR0Wi3nlB9PzqftQhfnJgyhB1jToZyDfAvQ7ZqfXD U0kg== MIME-Version: 1.0 X-Received: by 10.66.161.166 with SMTP id xt6mr1675870pab.169.1385822324123; Sat, 30 Nov 2013 06:38:44 -0800 (PST) In-Reply-To: References: Date: Sun, 1 Dec 2013 01:38:43 +1100 Subject: Re: any lib to convert 3200+ pic to animated gif? From: Chris Angelico Cc: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385822333 news.xs4all.nl 16002 [2001:888:2000:d::a6]:55720 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60807 On Sun, Dec 1, 2013 at 1:21 AM, oyster wrote: > I want to make an animated GIF from 3200+ png > I searched and found http://code.google.com/p/visvis/source/browse/#hg/vvmovie > and I wrote: > allPic=glob.glob('*.png') > allPic.sort() > allPic=[Image.open(i) for i in allPic] > writeGif('lala3.gif',allPic, duration=0.5, dither=0) > > However I got > IOError: [Errno 24] Too many open files: 'out0572.png' Yes, trying to open 3200 files is likely to be a problem! The question is, how can you load them into memory one by one, and keep closing them? I'm not very familiar with PIL, but a glance at the code suggests that the Image.open() calls will create, but possibly not verify, the images. Does this work? images = [] for pic in allPic: img = Image.open(pic) img.verify() images.append(img) allPic = images Use that instead of your list comprehension. In theory, at least, that should abandon the file objects (not explicitly closing them, alas, but abandoning them should result in them being closed in CPython), so you ought to get them all opened and read. Otherwise, someone with more knowledge of PIL may be able to help. According to the PIL docs, this list may be more focussed on what you're trying to do, so if you don't get a response here, try there: https://mail.python.org/mailman/listinfo/image-sig Hope that helps! ChrisA