Reportlab Image object opens filehandles

norseman norseman at hughes.net
Fri Jul 11 02:03:21 CEST 2008


Daniel de Sousa Barros wrote:
> 
> ----- Original Message ----- From: "norseman" <norseman at hughes.net>
> To: "Daniel de Sousa Barros" <danielsb2 at hotmail.com>
> Cc: <python-list at python.org>
> Sent: Tuesday, July 08, 2008 6:49 PM
> Subject: Re: Reportlab Image object opens filehandles
> 
> 
>>
>> Daniel de Sousa Barros wrote:
>>> Hi Mr Robin,
>>>
>>> I saw your post:
>>> http://mail.python.org/pipermail/python-list/2003-September/224781.html
>>>
>>> I'm trying to append more than 1000 images into one PDF report, but i 
>>> get the IOError: Too many...
>>>
>>> know you a solution for it?
>>>
>>> Sorry by my english.... i'm brazilian and i'm learning english yet...
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> -- 
>>> http://mail.python.org/mailman/listinfo/python-list
>> ====================
>> If you are using Microsoft:
>>
>> First reaction:  Increase the system pagefile (virtual memory) size.
>>
>> Assuming lots of spare disk space you could change it to the 'on 
>> demand' or 'let system handle it' setting.  I don't know about Vista 
>> but the rest top out about 4(or 2?)Gig per pagefile per disk. Forgot 
>> which.
>>
>> I don't know what imagery handling software you have, but if able, you 
>> could consider 1) resizing images to final printed paper display size 
>> and 2) make sure they are at or below 200dpi and jpeg in format before 
>> entering them into the report.
>>
>> If you are in Linux:
>>
>> see the man pages on mkswap and swapon.  Use files for swapspace. Easy 
>> to create, easier to remove. Don't need to reconfigure hard drive. Can 
>> be on another mounted drive.  Use AbiWord or OpenOffice to set up text 
>> pictures and all, print to file (will be a postscript) and use 
>> ghostview (gv) to check results then use ghostscript (gs) to convert 
>> to pdf. Final review in xpdf.  ImageMagic's convert will do the image 
>> manipulations mentioned in last paragraph of Microsoft section and 
>> then some.  All programs mentioned in the Linux section plus the 
>> operating system are free for the download.
>>
>>
>> Steve
>> norseman at hughes.net
>>
> ====================================================
> 
> I'm trying to generate de report using reportlab + PIL.
> 
> This is the code:
> 
> ------------------------------------------------------------------------------------------ 
> 
> for i in lista:
>    colab = Paragraph(i[0], style('1_b'))
>    imagem = Image(i[1])  #i tried lazy=2, but i get an error like this : 
> "_file"
>    imagem.drawHeight = 18*cm * imagem.drawHeight / imagem.drawWidth
>    imagem.drawWidth = 18*cm
>    story.append(imagem)
>    dados = [
>                     [colab, ''],
>                     [imagem, '']
>                 ]
>     tabela = Table(dados, [19.3*cm, 0.01*cm], repeatRows=True)
>     tabela.hAlign = "LEFT"
>     story.append(tabela)
>     story.append(Spacer(0*cm, 1*cm))
> doc.build(story, onFirstPage = cabecalhoRetrato, 
> onLaterPages=cabecalhoRetrato)
> ----------------------------------------------------------------------------------------------- 
> 
> 
> I only need to increase the virtual memory? How i do it? I'm using 
> windows xp.
> 
> 
================================================

Click Start/settings/control panel/system/advanced/settings(in \
performance area)/advanced/change

set System managed size on
click SET box to right of above line
click positives (OK APPLY etc.) all way out, system will probably reboot

what is 'cm' in your code?   In my world it means centimeter.

If you are trying to create full scale templates via raster methods you
will probably need more than 'Mom's" email machine. Junior's whiz-bang
game computer box probably won't work either.

Even at 72dpi
(72*72)*((18*2.54)*(18*2.54))*3
   5184 *(   45.72 * 45.72) * 3
   5184 *    2090.318   * 3
      10,836,208 * 3
         35,508,625.536 bytes per image
72dpi is normal for PDF/Postscript
5184 is dots per square inch
2090.318 is square inches per image
3 is one byte each, red,green,blue

Add margins and offsets and space between and.... even without that,
35.5 million times 1000 = 35500 million or 35.5 Gigabytes !!!?
In one file?  Microsoft is going to have a problem with you. :)


If that is what you are trying to do - reach me direct. I'll show you
how.  One of my photos takes 4 DVD's  AFTER a 15 to 1 reduction in size.
Can't find a calculator?  4*4.5*15 = 270Gigs uncompressed, more or less.


Steve
norseman at hughes.net





More information about the Python-list mailing list