@check_page<EOL><INDENT>def image(self, name, x=None, y=None, w=<NUM_LIT:0>,h=<NUM_LIT:0>,type='<STR_LIT>',link='<STR_LIT>'):<DEDENT>
if not name in self.images:<EOL><INDENT>if(type=='<STR_LIT>'):<EOL><INDENT>pos=name.rfind('<STR_LIT:.>')<EOL>if(not pos):<EOL><INDENT>self.error('<STR_LIT>'+name)<EOL><DEDENT>type=substr(name,pos+<NUM_LIT:1>)<EOL><DEDENT>type=type.lower()<EOL>if(type=='<STR_LIT>' or type=='<STR_LIT>'):<EOL><INDENT>info=self._parsejpg(name)<EOL><DEDENT>elif(type=='<STR_LIT>'):<EOL><INDENT>info=self._parsepng(name)<EOL><DEDENT>else:<EOL><INDENT>succeed_parsing = False<EOL>parsing_functions = [self._parsejpg,self._parsepng,self._parsegif]<EOL>for pf in parsing_functions:<EOL><INDENT>try:<EOL><INDENT>info = pf(name)<EOL>succeed_parsing = True<EOL>break;<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if not succeed_parsing:<EOL><INDENT>mtd='<STR_LIT>'+type<EOL>if not hasattr(self,mtd):<EOL><INDENT>self.error('<STR_LIT>'+type)<EOL><DEDENT>info=getattr(self, mtd)(name)<EOL><DEDENT>mtd='<STR_LIT>'+type<EOL>if not hasattr(self,mtd):<EOL><INDENT>self.error('<STR_LIT>'+type)<EOL><DEDENT>info=getattr(self, mtd)(name)<EOL><DEDENT>info['<STR_LIT:i>']=len(self.images)+<NUM_LIT:1><EOL>self.images[name]=info<EOL><DEDENT>else:<EOL><INDENT>info=self.images[name]<EOL><DEDENT>if(w==<NUM_LIT:0> and h==<NUM_LIT:0>):<EOL><INDENT>w=info['<STR_LIT:w>']/self.k<EOL>h=info['<STR_LIT:h>']/self.k<EOL><DEDENT>elif(w==<NUM_LIT:0>):<EOL><INDENT>w=h*info['<STR_LIT:w>']/info['<STR_LIT:h>']<EOL><DEDENT>elif(h==<NUM_LIT:0>):<EOL><INDENT>h=w*info['<STR_LIT:h>']/info['<STR_LIT:w>']<EOL><DEDENT>if y is None:<EOL><INDENT>if (self.y + h > self.page_break_trigger and not self.in_footer and self.accept_page_break()):<EOL><INDENT>x = self.x<EOL>self.add_page(self.cur_orientation)<EOL>self.x = x<EOL><DEDENT>y = self.y<EOL>self.y += h<EOL><DEDENT>if x is None:<EOL><INDENT>x = self.x<EOL><DEDENT>self._out(sprintf('<STR_LIT>',w*self.k,h*self.k,x*self.k,(self.h-(y+h))*self.k,info['<STR_LIT:i>']))<EOL>if(link):<EOL><INDENT>self.link(x,y,w,h,link)<EOL><DEDENT>
Put an image on the page