Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.05; 'memory.': 0.07; 'library?': 0.09; 'pointers': 0.09; 'python': 0.11; "wouldn't": 0.14; 'directory)': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'iterating': 0.16; 'message- id:@timgolden.me.uk': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject:Converting': 0.16; 'subject:folder': 0.16; 'tjg': 0.16; 'wrote:': 0.18; 'library': 0.18; 'appears': 0.22; 'header:User-Agent:1': 0.23; 'harry': 0.24; 'file.': 0.24; "haven't": 0.24; 'script': 0.25; 'asking': 0.27; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; "i'm": 0.30; 'code': 0.31; 'subject:per': 0.31; 'file': 0.32; 'quite': 0.32; 'problem': 0.35; 'convert': 0.35; 'hundreds': 0.35; 'usual': 0.35; 'but': 0.35; 'done': 0.36; 'too': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'files': 0.38; 'pdf': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; "you're": 0.61; 'save': 0.62; 'dear': 0.65; 'sample': 0.67; 'side': 0.67; 'internet': 0.71; 'from:addr:mail': 0.83; 'about?': 0.84; 'hundred': 0.95 Date: Thu, 16 Jan 2014 19:41:04 +0000 From: Tim Golden User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Converting folders of jpegs to single pdf per folder References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389901256 news.xs4all.nl 2960 [2001:888:2000:d::a6]:39877 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64101 On 16/01/2014 19:11, Harry Spier wrote: > > Dear list members, > > I have a directory that contains about a hundred subdirectories named > J0001,J0002,J0003 . . . etc. > Each of these subdirectories contains about a hundred JPEGs named > P001.jpg, P002.jpg, P003.jpg etc. > > I need to write a python script that will cycle thru each directory and > convert ALL JPEGs in each directory into a single PDF file and save > these PDF files (one per directory) to an output file. > > Any pointers on how to do this with a Python script would be > appreciated. Reading on the internet it appears that using ImageMagick > wouldn't work because of using too much memory. Can this be done using > the Python Image Library or some other library? Any sample code would > also be appreciated. The usual go-to library for PDF generation is ReportLab. I haven't used it for a long while but I'm quite certain it would have no problem including images. Do I take it that it's the PDF-generation side of things you're asking about? Or do you need help iterating over hundreds of directories and files? TJG