Modify

Opened 14 years ago

Closed 7 years ago

#6767 closed defect (worksforme)

Conversion to PDF fails on RGBA PNG images.

Reported by: johannj@… Owned by: Álvaro Iradier
Priority: normal Component: TracWikiPrintPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

AttributeError: 'NoneType' object has no attribute 'bands'

#   File "c:\python25\lib\site-packages\Trac-0.11.6-py2.5-win32.egg\trac\web\main.py", line 450, in  _dispatch_request
Code fragment:

 445. try:
 446. if not env and env_error:
 447. raise HTTPInternalError(env_error)
 448. try:
 449. dispatcher = RequestDispatcher(env)
 450. dispatcher.dispatch(req)
 451. except RequestDone:
 452. pass
 453. resp = req._response or []
 454.  
 455. except HTTPException, e:

Local variables:
Name	Value
after 	[u' except RequestDone:', u' pass', u' resp = ...
before 	[u' try:', u' if not env and env_error:', u' raise ...
dispatcher 	<trac.web.main.RequestDispatcher object at 0x0424C370>
e 	AttributeError("'NoneType' object has no attribute 'bands'",)
env 	<trac.env.Environment object at 0x038C1C70>
env_error 	None
exc_info 	(<type 'exceptions.AttributeError'>, AttributeError("'NoneType' object has ...
filename 	'c:\\python25\\lib\\site-packages\\Trac-0.11.6-py2.5-win32.egg\\trac\\web\\ ...
frames 	[{'function': '_dispatch_request', 'lines_before': [u' try:', u' ...
has_admin 	True
line 	u' dispatcher.dispatch(req)'
lineno 	449
message 	u"AttributeError: 'NoneType' object has no attribute 'bands'"
req 	<Request "GET u'/wiki/CoDeSys'">
resp 	[]
tb 	<traceback object at 0x052FE148>
tb_hide 	None
traceback 	u'Traceback (most recent call last):\n File ...
# File "c:\python25\lib\site-packages\Trac-0.11.6-py2.5-win32.egg\trac\web\main.py", line 206, in dispatch
Code fragment:

 201. req.args.get('__FORM_TOKEN') != req.form_token:
 202. raise HTTPBadRequest('Missing or invalid form token. '
 203. 'Do you have cookies enabled?')
 204.  
 205. # Process the request and render the template
 206. resp = chosen_handler.process_request(req)
 207. if resp:
 208. if len(resp) == 2: # Clearsilver
 209. chrome.populate_hdf(req)
 210. template, content_type = \
 211. self._post_process_request(req, *resp)

Local variables:
Name	Value
chosen_handler 	<trac.wiki.web_ui.WikiModule object at 0x0424C7D0>
chrome 	<trac.web.chrome.Chrome object at 0x04244390>
err 	(<type 'exceptions.AttributeError'>, AttributeError("'NoneType' object has ...
handler 	<trac.wiki.web_ui.WikiModule object at 0x0424C7D0>
req 	<Request "GET u'/wiki/CoDeSys'">
self 	<trac.web.main.RequestDispatcher object at 0x0424C370>
# File "c:\python25\lib\site-packages\Trac-0.11.6-py2.5-win32.egg\trac\wiki\web_ui.py", line 165, in process_request
Code fragment:

 160. else:
 161. format = req.args.get('format')
 162. if format:
 163. Mimeview(self.env).send_converted(req, 'text/x-trac-wiki',
 164. versioned_page.text,
 165. format, versioned_page.name)
 166. return self._render_view(req, versioned_page)
 167.  
 168. # ITemplateProvider methods
 169.  
 170. def get_htdocs_dirs(self):

Local variables:
Name	Value
action 	'view'
format 	u'pdfarticle'
old_version 	None
page 	<trac.wiki.model.WikiPage object at 0x04EB34B0>
pagename 	u'CoDeSys'
req 	<Request "GET u'/wiki/CoDeSys'">
self 	<trac.wiki.web_ui.WikiModule object at 0x0424C7D0>
version 	None
versioned_page 	<trac.wiki.model.WikiPage object at 0x0533BB50>
# File "c:\python25\lib\site-packages\Trac-0.11.6-py2.5-win32.egg\trac\mimeview\api.py", line 961, in send_converted
Code fragment:

 956. """Helper method for converting `content` and sending it directly.
 957.  
 958. `selector` can be either a key or a MIME Type."""
 959. from trac.web import RequestDone
 960. content, output_type, ext = self.convert_content(req, in_type,
 961. content, selector)
 962. if isinstance(content, unicode):
 963. content = content.encode('utf-8')
 964. req.send_response(200)
 965. req.send_header('Content-Type', output_type)
 966. req.send_header('Content-Length', len(content))

Local variables:
Name	Value
RequestDone 	<class 'trac.web.api.RequestDone'>
content 	u'= CoDeSys PLC Environment =\r\n== List of Items ==\r\nTo run the CoDeSys ...
filename 	u'CoDeSys'
in_type 	'text/x-trac-wiki'
req 	<Request "GET u'/wiki/CoDeSys'">
selector 	u'pdfarticle'
self 	<trac.mimeview.api.Mimeview object at 0x043ACE90>
# File "c:\python25\lib\site-packages\Trac-0.11.6-py2.5-win32.egg\trac\mimeview\api.py", line 669, in convert_content
Code fragment:

 664. 'to %(new)s', old=mimetype, new=key))
 665.  
 666. # First successful conversion wins
 667. for ck, name, ext, input_mimettype, output_mimetype, quality, \
 668. converter in candidates:
 669. output = converter.convert_content(req, mimetype, content, ck)
 670. if not output:
 671. continue
 672. return (output[0], output[1], ext)
 673. raise TracError(_('No available MIME conversions from %(old)s to '
 674. '%(new)s', old=mimetype, new=key))

Local variables:
Name	Value
c 	('printhtml', 'Printable HTML', 'html', 'text/x-trac-wiki', 'text/html', ...
candidates 	[('pdfarticle', 'PDF Article', 'pdf', 'text/x-trac-wiki', ...
ck 	'pdfarticle'
content 	u'= CoDeSys PLC Environment =\r\n== List of Items ==\r\nTo run the CoDeSys ...
converter 	<wikiprint.wikiprint.WikiToPDFPage object at 0x043B3130>
ext 	'pdf'
filename 	None
full_mimetype 	'text/x-trac-wiki'
input_mimettype 	'text/x-trac-wiki'
key 	u'pdfarticle'
mimetype 	'text/x-trac-wiki'
name 	'PDF Article'
output_mimetype 	'application/pdf'
quality 	7
req 	<Request "GET u'/wiki/CoDeSys'">
self 	<trac.mimeview.api.Mimeview object at 0x043ACE90>
url 	None
# File "build\bdist.win32\egg\wikiprint\wikiprint.py", line 381, in convert_content
Local variables:
Name	Value
anchor 	u'CoDeSysPLCEnvironment'
context 	<Context <Resource u'wiki:CoDeSys'>>
depth 	1
input_type 	'text/x-trac-wiki'
out 	<StringIO.StringIO instance at 0x052ED648>
outline 	<trac.wiki.formatter.OutlineFormatter object at 0x052DB130>
output_type 	'pdfarticle'
page 	<Markup u'<h1 id="CoDeSysPLCEnvironment"><a class="wiki" ...
page_name 	u'CoDeSys'
req 	<Request "GET u'/wiki/CoDeSys'">
self 	<wikiprint.wikiprint.WikiToPDFPage object at 0x043B3130>
text 	u'CoDeSys PLC Environment'
title 	u'CoDeSys PLC Environment'
wikipage 	<trac.wiki.model.WikiPage object at 0x0521BE70>
wikiprint 	<wikiprint.wikiprint.WikiPrint object at 0x0424C730>
# File "build\bdist.win32\egg\wikiprint\wikiprint.py", line 235, in html_to_pdf
Local variables:
Name	Value
auth_cookie 	'43aae47377755e207a6a8fae724f9bd2'
book 	False
css_data 	u'\nhtml {\n font-family: Helvetica; \n font-size: 10px; \n ...
cursor 	<trac.db.util.IterableCursor object at 0x05345D10>
date 	u'4.3.2010 12:37:20'
db 	<trac.db.pool.PooledConnection object at 0x051A0C60>
html_pages 	[<Markup u'<h1 id="CoDeSysPLCEnvironment"><a class="wiki" ...
loader 	<wikiprint.wikiprint.linkLoader instance at 0x051A0D50>
page 	'<html><head><meta http-equiv="Content-Type" content="text/html; ...
pdf_file 	<StringIO.StringIO instance at 0x052F2C38>
req 	<Request "GET u'/wiki/CoDeSys'">
self 	<wikiprint.wikiprint.WikiPrint object at 0x0424C730>
subject 	u'marel_base - CoDeSys'
title 	u'CoDeSys PLC Environment'
version 	'18'
# File "c:\python25\lib\site-packages\pisa-3.0.32-py2.5.egg\sx\pisa3\pisa_document.py", line 161, in pisaDocument
Code fragment:

 156.  
 157. # Use multibuild e.g. if a TOC has to be created
 158. if c.multiBuild:
 159. doc.multiBuild(c.story)
 160. else:
 161. doc.build(c.story)
 162.  
 163. # Add watermarks
 164. if pyPdf:
 165. for bgouter in c.pisaBackgroundList:
 166.

Local variables:
Name	Value
body 	<sx.pisa3.pisa_reportlab.PmlPageTemplate instance at 0x053B8DA0>
c 	<sx.pisa3.pisa_context.pisaContext instance at 0x04BCB2D8>
capacity 	102400
debug 	0
default_css 	u'\nhtml {\n font-family: Helvetica; \n font-size: 10px; \n ...
dest 	<StringIO.StringIO instance at 0x052F2C38>
doc 	<sx.pisa3.pisa_reportlab.PmlBaseDoc instance at 0x053B82B0>
encoding 	None
kw 	{'show_errors_as_pdf': True}
link_callback 	<bound method linkLoader.getFileName of <wikiprint.wikiprint.linkLoader ...
out 	<sx.pisa3.pisa_util.pisaTempFile object at 0x0537C150>
path 	None
raise_exception 	True
show_error_as_pdf 	False
src 	'<html><head><meta http-equiv="Content-Type" content="text/html; ...
x 	''
xhtml 	False
xml_output 	None
# File "c:\python25\lib\site-packages\reportlab-2.3-py2.5-win32.egg\reportlab\platypus\doctemplate.py", line 777, in build
Code fragment:

 772. canv._doctemplate = self
 773. while len(flowables):
 774. self.clean_hanging()
 775. try:
 776. first = flowables[0]
 777. self.handle_flowable(flowables)
 778. handled += 1
 779. except:
 780. #if it has trace info, add it to the traceback message.
 781. if hasattr(first, '_traceInfo') and first._traceInfo:
 782. exc = sys.exc_info()[1]

Local variables:
Name	Value
canv 	<reportlab.pdfgen.canvas.Canvas instance at 0x053B8E90>
canvasmaker 	<class reportlab.pdfgen.canvas.Canvas at 0x0411E750>
filename 	None
first 	PmlParagraph( 'style' 'style' 'autoLeading' 'autoLeading' ...
flowableCount 	24
flowables 	[PmlParagraph( 'style' 'style' 'keepWithNext' ...
handled 	14
self 	<sx.pisa3.pisa_reportlab.PmlBaseDoc instance at 0x053B82B0>
# File "c:\python25\lib\site-packages\reportlab-2.3-py2.5-win32.egg\reportlab\platypus\doctemplate.py", line 665, in handle_flowable
Code fragment:

 660. self.afterFlowable(f)
 661. else:
 662. frame = self.frame
 663. canv = self.canv
 664. #try to fit it then draw it
 665. if frame.add(f, canv, trySplit=self.allowSplitting):
 666. if not isinstance(f,FrameActionFlowable):
 667. self._curPageFlowableCount += 1
 668. self.afterFlowable(f)
 669. _addGeneratedContent(flowables,frame)
 670. else:

Local variables:
Name	Value
canv 	<reportlab.pdfgen.canvas.Canvas instance at 0x053B8E90>
f 	PmlParagraph( 'style' 'style' 'autoLeading' 'autoLeading' ...
flowables 	[PmlParagraph( 'style' 'style' 'keepWithNext' ...
frame 	<reportlab.platypus.frames.Frame instance at 0x053B8670>
self 	<sx.pisa3.pisa_reportlab.PmlBaseDoc instance at 0x053B82B0>
# File "c:\python25\lib\site-packages\reportlab-2.3-py2.5-win32.egg\reportlab\platypus\frames.py", line 174, in _add
Code fragment:

 169. raise LayoutError("Flowable %s (%sx%s points) too large for frame (%sx%s points)." % (
 170. flowable.__class__, w,h, aW,self._aH))
 171. return 0
 172. else:
 173. #now we can draw it, and update the current point.
 174. flowable.drawOn(canv, self._x + self._leftExtraIndent, y, _sW=aW-w)
 175. flowable.canv=canv
 176. if self._debug: logger.debug('drew %s' % flowable.identity())
 177. s = flowable.getSpaceAfter()
 178. y -= s
 179. if self._oASpace: self._prevASpace = s

Local variables:
Name	Value
a 	'_frame'
aW 	510.23622047244089
canv 	<reportlab.pdfgen.canvas.Canvas instance at 0x053B8E90>
flowable 	PmlParagraph( 'style' 'style' 'autoLeading' 'autoLeading' ...
h 	217.21678845784521
p 	70.866141732283495
s 	0
self 	<reportlab.platypus.frames.Frame instance at 0x053B8670>
trySplit 	1
w 	510.23622047244089
y 	553.80683358939882
# File "c:\python25\lib\site-packages\reportlab-2.3-py2.5-win32.egg\reportlab\platypus\flowables.py", line 105, in drawOn
Code fragment:

 100. x = x + _sW
 101. elif a not in ('LEFT',TA_LEFT):
 102. raise ValueError, "Bad hAlign value "+str(a)
 103. canvas.saveState()
 104. canvas.translate(x, y)
 105. self._drawOn(canvas)
 106. if hasattr(self, '_showBoundary') and self._showBoundary:
 107. #diagnostic tool support
 108. canvas.setStrokeColor(gray)
 109. canvas.rect(0,0,self.width, self.height)
 110. canvas.restoreState()

Local variables:
Name	Value
_sW 	0.0
canvas 	<reportlab.pdfgen.canvas.Canvas instance at 0x053B8E90>
self 	PmlParagraph( 'style' 'style' 'autoLeading' 'autoLeading' ...
x 	42.519685039370074
y 	553.80683358939882
# File "c:\python25\lib\site-packages\reportlab-2.3-py2.5-win32.egg\reportlab\platypus\flowables.py", line 89, in _drawOn
Code fragment:

  84. self.encoding = None
  85.  
  86. def _drawOn(self,canv):
  87. '''ensure canv is set on and then draw'''
  88. self.canv = canv
  89. self.draw()#this is the bit you overload
  90. del self.canv
  91.  
  92. def drawOn(self, canvas, x, y, _sW=0):
  93. "Tell it to draw itself on the canvas. Do not override"
  94. if _sW and hasattr(self,'hAlign'):

Local variables:
Name	Value
canv 	<reportlab.pdfgen.canvas.Canvas instance at 0x053B8E90>
self 	PmlParagraph( 'style' 'style' 'autoLeading' 'autoLeading' ...
# File "c:\python25\lib\site-packages\pisa-3.0.32-py2.5.egg\sx\pisa3\pisa_reportlab.py", line 564, in draw
Code fragment:

 559. canvas.translate(
 560. (style.paddingLeft + style.borderLeftWidth),
 561. -1 * (style.paddingTop + style.borderTopWidth)) # + (style.leading / 4)))
 562.  
 563. # Call the base class draw method to finish up
 564. Paragraph.draw(self)
 565. canvas.restoreState()
 566.  
 567. # Reset color because we need it again if we run 2-PASS like we
 568. # do when using TOC
 569. style.backColor = bg

Local variables:
Name	Value
bg 	None
bp 	0
canvas 	<reportlab.pdfgen.canvas.Canvas instance at 0x053B8E90>
h 	217.21678845784521
leftIndent 	0.0
self 	PmlParagraph( 'style' 'style' 'autoLeading' 'autoLeading' ...
style 	<ParagraphStyle 'default29'>
w 	510.23622047244089
x 	0.0
y 	0
# File "c:\python25\lib\site-packages\pisa-3.0.32-py2.5.egg\sx\pisa3\reportlab_paragraph.py", line 1054, in draw
Code fragment:

1049.  
1050. def draw(self):
1051. #call another method for historical reasons. Besides, I
1052. #suspect I will be playing with alternate drawing routines
1053. #so not doing it here makes it easier to switch.
1054. self.drawPara(self.debug)
1055.  
1056. def breakLines(self, width):
1057. """
1058. Returns a broken line structure. There are two cases
1059.  

Local variables:
Name	Value
self 	PmlParagraph( 'style' 'style' 'autoLeading' 'autoLeading' ...
# File "c:\python25\lib\site-packages\pisa-3.0.32-py2.5.egg\sx\pisa3\reportlab_paragraph.py", line 1534, in drawPara
Code fragment:

1529. xs.f = f
1530. xs.style = style
1531. xs.autoLeading = autoLeading
1532.  
1533. tx._fontname,tx._fontsize = None, None
1534. dpl( tx, offset, lines[0], noJustifyLast and nLines==1)
1535. _do_post_text(tx)
1536.  
1537. #now the middle of the paragraph, aligned with the left margin which is our origin.
1538. for i in xrange(1, nLines):
1539. f = lines[i]

Local variables:
Name	Value
_offsets 	[0, 0]
alignment 	0
autoLeading 	'max'
bc 	None
bg 	None
blPara 	ParaLines( 'kind' 1 'lines' [FragLine( 'lineBreak' ...
bulletText 	None
bw 	0
canvas 	<reportlab.pdfgen.canvas.Canvas instance at 0x053B8E90>
cur_x 	0.0
cur_y 	14.802500000000009
debug 	False
dpl 	<function _leftDrawParaLineX at 0x0416D8F0>
f 	FragLine( 'lineBreak' True 'fontSize' 7.5 'descent' ...
leading 	11.25
leftIndent 	0.0
lim 	1
lines 	[FragLine( 'lineBreak' True 'fontSize' 7.5 'descent' ...
nLines 	2
noJustifyLast 	True
offset 	0
self 	PmlParagraph( 'style' 'style' 'autoLeading' 'autoLeading' ...
style 	<ParagraphStyle 'default29'>
tx 	<reportlab.pdfgen.textobject.PDFTextObject instance at 0x04BCB850>
xs 	ABag( 'links' [] 'leftIndent' 0.0 'backgroundFontSize' ...
# File "c:\python25\lib\site-packages\pisa-3.0.32-py2.5.egg\sx\pisa3\reportlab_paragraph.py", line 337, in _leftDrawParaLineX
Code fragment:

 332. if tx._x0!=x0:
 333. setXPos(tx,x0-tx._x0)
 334.  
 335. def _leftDrawParaLineX( tx, offset, line, last=0):
 336. setXPos(tx,offset)
 337. _putFragLine(offset, tx, line)
 338. setXPos(tx,-offset)
 339.  
 340. def _centerDrawParaLineX( tx, offset, line, last=0):
 341. m = offset+0.5*line.extraSpace
 342. setXPos(tx,m)

Local variables:
Name	Value
last 	False
line 	FragLine( 'lineBreak' True 'fontSize' 7.5 'descent' ...
offset 	0
tx 	<reportlab.pdfgen.textobject.PDFTextObject instance at 0x04BCB850>
# File "c:\python25\lib\site-packages\pisa-3.0.32-py2.5.egg\sx\pisa3\reportlab_paragraph.py", line 217, in _putFragLine
Code fragment:

 212. if txfs is None:
 213. txfs = xs.style.fontSize
 214. iy0,iy1 = imgVRange(h,cbDefn.valign,txfs)
 215. cur_x_s = cur_x + nSpaces*ws
 216. # print "draw", id(f), id(cbDefn.image), repr(dal), cur_y, iy0, iy1, h
 217. tx._canvas.drawImage(cbDefn.image.getImage(),cur_x_s,cur_y+iy0,w,h,mask='auto')
 218. cur_x += w
 219. cur_x_s += w
 220. setXPos(tx,cur_x_s-tx._x0)
 221. else:
 222. name = cbDefn.name

Local variables:
Name	Value
ascent 	202.4142884578452
autoLeading 	'max'
cbDefn 	ABag( 'width' 508.23622047244089 'fontName' 'Helvetica' ...
cur_x 	0.0
cur_x_s 	0.0
cur_y 	14.802500000000009
dal 	True
descent 	1.875
f 	ParaFrag( 'borderLeftWidth' 1 'fontName' 'Helvetica' ...
h 	203.9142884578452
iy0 	-1.5
iy1 	202.4142884578452
kind 	'img'
leading 	204.2892884578452
line 	FragLine( 'lineBreak' True 'fontSize' 7.5 'descent' ...
nSpaces 	0
olb 	None
tx 	<reportlab.pdfgen.textobject.PDFTextObject instance at 0x04BCB850>
txfs 	7.5
w 	508.23622047244089
words 	[ParaFrag( 'borderLeftWidth' 1 'fontName' 'Helvetica' ...
ws 	0
x0 	0.0
xs 	ABag( 'links' [] 'leftIndent' 0.0 'backgroundFontSize' ...
# File "c:\python25\lib\site-packages\reportlab-2.3-py2.5-win32.egg\reportlab\pdfgen\canvas.py", line 690, in drawImage
Code fragment:

 685. # say it is an XObject. Does it exist yet?
 686. regName = self._doc.getXObjectName(name)
 687. imgObj = self._doc.idToObject.get(regName, None)
 688. if not imgObj:
 689. #first time seen, create and register the PDFImageXobject
 690. imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)
 691. imgObj.name = name
 692. self._setXObjects(imgObj)
 693. self._doc.Reference(imgObj, regName)
 694. self._doc.addForm(name, imgObj)
 695. smask = getattr(imgObj,'_smask',None)

Local variables:
Name	Value
anchor 	'c'
height 	203.9142884578452
image 	<sx.pisa3.pisa_reportlab.PmlImageReader object at 0x05354210>
imgObj 	None
mask 	'auto'
name 	'ce6928f4b9907b27b50e88be22f29dbd'
preserveAspectRatio 	False
regName 	'FormXob.ce6928f4b9907b27b50e88be22f29dbd'
self 	<reportlab.pdfgen.canvas.Canvas instance at 0x053B8E90>
width 	508.23622047244089
x 	0.0
y 	13.302500000000009
# File "c:\python25\lib\site-packages\reportlab-2.3-py2.5-win32.egg\reportlab\pdfbase\pdfdoc.py", line 2033, in __init__
Code fragment:

2028. self.mask = mask
2029.  
2030. if source is None:
2031. pass # use the canned one.
2032. elif hasattr(source,'jpeg_fh'):
2033. self.loadImageFromSRC(source) #it is already a PIL Image
2034. else:
2035. # it is a filename
2036. import os
2037. ext = string.lower(os.path.splitext(source)[1])
2038. src = open_for_read(source)

Local variables:
Name	Value
mask 	'auto'
name 	'ce6928f4b9907b27b50e88be22f29dbd'
self 	<reportlab.pdfbase.pdfdoc.PDFImageXObject instance at 0x054E6698>
source 	<sx.pisa3.pisa_reportlab.PmlImageReader object at 0x05354210>
# File "c:\python25\lib\site-packages\reportlab-2.3-py2.5-win32.egg\reportlab\pdfbase\pdfdoc.py", line 2101, in loadImageFromSRC
Code fragment:

2096. self.loadImageFromJPEG(fp)
2097. else:
2098. zlib = import_zlib()
2099. if not zlib: return
2100. self.width, self.height = im.getSize()
2101. raw = im.getRGBData()
2102. #assert len(raw) == self.width*self.height, "Wrong amount of data for image expected %sx%s=%s got %s" % (self.width,self.height,self.width*self.height,len(raw))
2103. self.streamContent = pdfutils._AsciiBase85Encode(zlib.compress(raw))
2104. self.colorSpace= _mode2CS[im.mode]
2105. self.bitsPerComponent = 8
2106. self._filters = 'ASCII85Decode','FlateDecode' #'A85','Fl'

Local variables:
Name	Value
fp 	None
im 	<sx.pisa3.pisa_reportlab.PmlImageReader object at 0x05354210>
self 	<reportlab.pdfbase.pdfdoc.PDFImageXObject instance at 0x054E6698>
zlib 	<module 'zlib' (built-in)>
# File "c:\python25\lib\site-packages\pisa-3.0.32-py2.5.egg\sx\pisa3\pisa_reportlab.py", line 313, in getRGBData
Code fragment:

 308. self.mode = 'RGB'
 309. else:
 310. im = self._image
 311. mode = self.mode = im.mode
 312. if mode == 'RGBA':
 313. self._dataA = PmlImageReader(im.split()[3])
 314. im = im.convert('RGB')
 315. self.mode = 'RGB'
 316. elif mode not in ('L', 'RGB', 'CMYK'):
 317. im = im.convert('RGB')
 318. self.mode = 'RGB'

Local variables:
Name	Value
im 	<PngImagePlugin.PngImageFile image mode=RGBA size=820x329 at 0x54E8058>
mode 	'RGBA'
self 	<sx.pisa3.pisa_reportlab.PmlImageReader object at 0x05354210>
# File "c:\python25\lib\site-packages\PIL-1.1.7-py2.5-win32.egg\Image.py", line 1497, in split
Code fragment:

1492. # @return A tuple containing bands.
1493.  
1494. def split(self):
1495. "Split image into bands"
1496.  
1497. if self.im.bands == 1:
1498. ims = [self.copy()]
1499. else:
1500. ims = []
1501. self.load()
1502. for i in range(self.im.bands):

Local variables:
Name	Value
self 	<PngImagePlugin.PngImageFile image mode=RGBA size=820x329 at 0x54E8058>

Attachments (0)

Change History (9)

comment:1 Changed 14 years ago by Álvaro Iradier

Status: newassigned

I noticed exactly the same problem just today. It fails with 32 bits PNG files, but works with 24 bits PNG files (no alpha channel).

The problem, however, might be related to PIL (Python Imaging Library) or another library, not to TracWikiPrintPlugin.

comment:2 Changed 14 years ago by johannj@…

comment:3 Changed 14 years ago by johannj@…

I fixed my local copy of PIL by moving the self.load() in the split function out of the else:

    def split(self):
        "Split image into bands"

        self.load()
        if self.im.bands == 1:
            ims = [self.copy()]
        else:
            ims = []
            for i in range(self.im.bands):
                ims.append(self._new(self.im.getband(i)))
        return tuple(ims)

then it works as intended.

comment:4 Changed 14 years ago by Álvaro Iradier

Another workaround might be installing PIL 1.1.6:

easy-install PIL=1.1.6

I guess that should work, I'll try myself tomorrow.

comment:5 Changed 14 years ago by anonymous

This is the right one:

easy-install PIL==1.1.6

comment:6 Changed 14 years ago by anonymous

Owner: changed from Álvaro Iradier to lol
Status: assignednew

comment:7 Changed 14 years ago by Álvaro Iradier

Owner: changed from lol to Álvaro Iradier
Status: newassigned

LOL, who was 'lol'?

comment:8 in reply to:  5 Changed 14 years ago by Lucas Rangit MAGASWERAN

For reference, on an Ubuntu 9.10 64-bit server I had the same problem with PIL 1.1.7 but could not get PIL 1.1.6 detecting the installed libraries (Installed via $ sudo easy_install -U http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz) as shown below:

--------------------------------------------------------------------
PIL 1.1.6 BUILD SUMMARY
--------------------------------------------------------------------
version       1.1.6
platform      linux2 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
              [GCC 4.4.1]
--------------------------------------------------------------------
*** TKINTER support not available
*** JPEG support not available
*** ZLIB (PNG/ZIP) support not available
*** FREETYPE2 support not available
--------------------------------------------------------------------

To resolve this I removed the egg manually installed the Ubuntu packages when I noticed it was at version 1.1.6 on karmic.

comment:9 Changed 7 years ago by Ryan J Ollos

Resolution: worksforme
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Álvaro Iradier.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.