Attachment 'Gallery2.patch'

Download

   1 --- C:\download\pmswiki\gallery2\Gallery2-1.3.5-15.py	2006-07-24 11:14:42.336758000 +0200
   2 +++ Gallery2.py	2006-07-27 20:19:22.463233600 +0200
   3 @@ -315,7 +315,7 @@
   4         2005-11-12: Version 1.3.5-12 bug fixed for image_for_webnail=1            
   5                                      bug fixed at last cell table end tr instead of td
   6                                      bug fixed don't render a filename as WikiName
   7 -                                    bug fixed " is allowed in alias name
   8 +                                    bug fixed \" is allowed in alias name
   9                                      bug fixed ' is allowed in alias name
  10                                      bug fixed linebreak by a space in alias  
  11                                      not quite a bug but makes it very difficult to code in 
  12 @@ -342,7 +342,8 @@
  13  from MoinMoin import wikiutil, config
  14  from MoinMoin.Page import Page
  15  from MoinMoin.parser import wiki
  16 -
  17 +from xml.sax.saxutils import quoteattr
  18 +import sha
  19  
  20  def images2swf(request,images,swf_filename,swf_fps,description,exif_date):
  21  ## this code is based on 
  22 @@ -401,6 +402,26 @@
  23      
  24    #  os.system(cmd)    
  25  
  26 +def removeControlChar(text):
  27 +    ret = ""
  28 +    for c in text:
  29 +        if ord(c) < 32:
  30 +            continue
  31 +        ret += c
  32 +    return ret
  33 +
  34 +def saveImageProgressiveIfPossible(im, filename, img_type):
  35 +    progressive = 0
  36 +    if img_type == "JPEG":
  37 +        progressive = 1
  38 +    try:
  39 +        im.save(filename, img_type, progressive=progressive)
  40 +    except IOError, e:
  41 +        if e.args[0] == 'encoder error -2 when writing image file':
  42 +            im.save(filename, img_type)
  43 +        else:
  44 +            raise
  45 +
  46  def server(request):
  47      if request.is_ssl:
  48          url_pattern = 'https'
  49 @@ -412,19 +433,20 @@
  50                                 "server_name":request.server_name, 
  51                                 "server_port":str(request.server_port)}
  52  
  53 -def show_tools_restricted(pagename,this_target,thumbnail_width,full,alias,target,exif_date,request):
  54 +def show_tools_restricted(pagename,this_target,thumbnail_width,full,alias,target,exif_date,request, pull_from_dir):
  55      if request.user.may.delete(pagename):
  56 -        return tools_restricted_html(pagename,this_target,thumbnail_width,full,alias,target,exif_date,request)
  57 +        return tools_restricted_html(pagename,this_target,thumbnail_width,full,alias,target,exif_date,request, pull_from_dir)
  58      else:
  59          return ''    
  60  
  61 -def tools_restricted_html(pagename,this_target,thumbnail_width,full,alias,target,exif_date,request):
  62 +def tools_restricted_html(pagename,this_target,thumbnail_width,full,alias,target,exif_date,request, pull_from_dir):
  63      text = '''
  64                     <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
  65                          <td>
  66                              <input type="hidden" name="action" value="gallery2image">
  67                              <input type="hidden" name="do" value="RL">
  68                              <input type="hidden" name="target" value="%(this_target)s">
  69 +                            <input type="hidden" name="pull_from_dir" value="%(pull_from_dir)s">
  70                              <input type="image" value="submit" src="%(server)s%(wiki)s/modern/img/to_left.png" title="rotate to left">
  71                          </td>
  72                      </form>
  73 @@ -433,6 +455,7 @@
  74                              <input type="hidden" name="action" value="gallery2image">
  75                              <input type="hidden" name="do" value="RR">
  76                              <input type="hidden" name="target" value="%(this_target)s">
  77 +                            <input type="hidden" name="pull_from_dir" value="%(pull_from_dir)s">
  78                              <input type="image"  value="submit" src="%(server)s%(wiki)s/modern/img/to_right.png" title="rotate to right" >
  79                          </td>
  80                      </form>
  81 @@ -441,6 +464,7 @@
  82                              <input type="hidden" name="action" value="gallery2image">
  83                              <input type="hidden" name="do" value="RM">
  84                              <input type="hidden" name="target" value="%(this_target)s">
  85 +                            <input type="hidden" name="pull_from_dir" value="%(pull_from_dir)s">
  86                              <input type="image" value="submit" src="%(server)s%(wiki)s/modern/img/to_bak.png" title="move to bak" >
  87                          </td>
  88                      </form>''' %  {
  89 @@ -448,13 +472,14 @@
  90              "wiki": request.cfg.url_prefix,  
  91              'baseurl': request.getScriptname(),
  92              "pagename": pagename,
  93 -            "this_target": this_target}                   
  94 +            "this_target": this_target,
  95 +            "pull_from_dir":pull_from_dir,
  96 +            }                   
  97      return text                
  98      
  99 -def tools_html(pagename,this_image,thumbnail_width,full,alias,target,exif_date,request):
 100 -    text = '''
 101 -            <TABLE align="center" width="%(thumbnail_width)s">
 102 -                <TR>
 103 +def tools_html(pagename,this_image,thumbnail_width,full,alias,target,exif_date,request,pull_from_dir):
 104 +    if not pull_from_dir:
 105 +        actionAttachFile = '''
 106                      <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
 107                          <td>
 108                              <input type="hidden" name="action" value="AttachFile">
 109 @@ -463,12 +488,19 @@
 110                              <input type="image" value="submit" src="%(server)s%(wiki)s/modern/img/to_full.png" title="load image">
 111                          </td>
 112                      </form>
 113 +'''
 114 +    else:
 115 +        actionAttachFile = ''
 116 +    text = ('''
 117 +            <TABLE align="center" width="%(thumbnail_width)s">
 118 +                <TR>
 119 +                    ''' + actionAttachFile + '''
 120                      <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
 121                          <td>
 122                              <input type="hidden" name="action" value="gallery2image">
 123                              <input type="hidden" name="do" value="VS">
 124 -                            <input type="hidden" name="full" value='%(full)s'>
 125 -                            <input type="hidden" name="alias" value='%(alias)s'>
 126 +                            <input type="hidden" name="full" value=%(full)s>
 127 +                            <input type="hidden" name="alias" value=%(alias)s>
 128                              <input type="hidden" name="target" value='%(target)s'>
 129                              <input type="hidden" name="exif_date" value='%(exif_date)s'>
 130                              <input type="image" value="submit" src="%(server)s%(wiki)s/modern/img/to_slide.png" title="slide_show" >
 131 @@ -476,18 +508,18 @@
 132                      </form>
 133                      %(show_tools_restricted)s
 134                  </TR>
 135 -            </TABLE>'''   %  {
 136 +            </TABLE>''')   %  {
 137              "server": server(request),
 138              "wiki": request.cfg.url_prefix,  
 139              'baseurl': request.getScriptname(),
 140              "pagename": pagename,
 141              "thumbnail_width": thumbnail_width,
 142 -            "full": full,
 143 -            "alias": alias,
 144 +            "full": quoteattr(full),
 145 +            "alias": quoteattr(alias),     # need to use quoteattr if text include character ' or "
 146              "exif_date": exif_date,
 147              "target": target,
 148              "this_target": this_image,
 149 -            "show_tools_restricted": show_tools_restricted(pagename,this_image,thumbnail_width,full,alias,target,exif_date,request)
 150 +            "show_tools_restricted": show_tools_restricted(pagename,this_image,thumbnail_width,full,alias,target,exif_date,request,pull_from_dir),
 151              } 
 152     
 153      return text
 154 @@ -513,21 +545,21 @@
 155     else:
 156          return ''
 157                 
 158 -def show_tools_mode2(show_tools,pagename,this_target,thumbnail_width,full,alias,target,exif_date,request):  
 159 +def show_tools_mode2(show_tools,pagename,this_target,thumbnail_width,full,alias,target,exif_date,request,pull_from_dir):  
 160      if show_tools == '1' :
 161 -        return "<td align=""center""> %s </td>" % tools_html(pagename,this_target,thumbnail_width,full,alias,target,exif_date,request)
 162 +        return "<td align=""center""> %s </td>" % tools_html(pagename,this_target,thumbnail_width,full,alias,target,exif_date,request,pull_from_dir)
 163      else:
 164          return ''
 165  
 166 -def mode2_html(pagename,border_thick,width,thumbnail_width,text_width,full,this_image,alias,this_alias,exif_date,this_exif_date,target,this_target,submit,show_tools,show_date,show_alias,request):
 167 +def mode2_html(pagename,border_thick,width,thumbnail_width,text_width,full,this_image,alias,this_alias,exif_date,this_exif_date,target,this_target,submit,show_tools,show_date,show_alias,request,pull_from_dir):
 168      text = '''
 169      <tr valign="center">
 170          <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
 171              <td align="center" valign="center" width="%(thumbnail_width)s">
 172                  <input type="hidden" name="action" value="gallery2image">
 173                  <input type="hidden" name="do" value="VS">
 174 -                <input type="hidden" name="full" value='%(full)s'>
 175 -                <input type="hidden" name="alias" value='%(alias)s'>
 176 +                <input type="hidden" name="full" value=%(full)s>
 177 +                <input type="hidden" name="alias" value=%(alias)s>
 178                  <input type="hidden" name="exif_date" value='%(exif_date)s'>
 179                  <input type="hidden" name="target" value='%(target)s'>
 180                  <input type="image" value="submit" src="%(server)s%(submit)s">
 181 @@ -540,21 +572,21 @@
 182       "baseurl": request.getScriptname(),
 183       "pagename": pagename,
 184       "thumbnail_width": thumbnail_width,
 185 -     "full": full,
 186 -     "alias": alias,
 187 +     "full": quoteattr(full),
 188 +     "alias": quoteattr(alias),
 189       "exif_date": exif_date,
 190       "target": target,
 191       "submit": submit,
 192 -     "tools_html": show_tools_mode2(show_tools,pagename,this_image,thumbnail_width,full,alias,target,exif_date,request),
 193 +     "tools_html": show_tools_mode2(show_tools,pagename,this_image,thumbnail_width,full,alias,target,exif_date,request,pull_from_dir),
 194       "date_html": show_date_mode2(show_date,this_exif_date),
 195       "alias_html": show_alias_mode2(show_alias,thumbnail_width,this_alias,text_width)
 196       }
 197      
 198      return text
 199  
 200 -def show_tools_mode1(show_tools,pagename,this_image,thumbnail_width,full,alias,target,exif_date,request):  
 201 -    if show_tools == '1' :
 202 -        text="<tr><td align=""center"">%s </td></tr>" % tools_html(pagename,this_image,thumbnail_width,full,alias,target,exif_date,request)
 203 +def show_tools_mode1(show_tools,pagename,this_image,thumbnail_width,full,alias,target,exif_date,request,pull_from_dir):  
 204 +    if show_tools == '1':
 205 +        text="<tr><td align=""center"">%s </td></tr>" % tools_html(pagename,this_image,thumbnail_width,full,alias,target,exif_date,request, pull_from_dir)
 206      else:
 207          text = ''
 208      return text        
 209 @@ -581,7 +613,7 @@
 210         return ''     
 211         
 212  def mode1_html(pagename,border_thick,width,thumbnail_width,text_width,full,this_image,alias,this_alias,exif_date,this_exif_date,target,this_target,submit,
 213 -               show_tools,show_date,show_alias,request):
 214 +               show_tools,show_date,show_alias,request,pull_from_dir):
 215     text = '''
 216  <table width="%(thumbnail_width)s" align="center" valign="center">
 217      <TR align="center" valign="center">
 218 @@ -589,10 +621,11 @@
 219              <td align="center" valign="middle" width="%(thumbnail_width)s">
 220                  <input type="hidden" name="action" value="gallery2image">
 221                  <input type="hidden" name="do" value="VS">
 222 -                <input type="hidden" name="full" value='%(full)s'>
 223 -                <input type="hidden" name="alias" value='%(alias)s'>
 224 +                <input type="hidden" name="full" value=%(full)s>
 225 +                <input type="hidden" name="alias" value=%(alias)s>
 226                  <input type="hidden" name="exif_date" value='%(exif_date)s'>
 227                  <input type="hidden" name="target" value='%(target)s'>
 228 +                <input type="hidden" name="pull_from_dir" value='%(pull_from_dir)s'>
 229                  <input type="image" value="submit" src="%(server)s%(submit)s" >
 230              </td>
 231          </form>
 232 @@ -604,20 +637,21 @@
 233       "server" : server(request), 
 234       "baseurl": request.getScriptname() ,
 235       "pagename":pagename,
 236 -     "full":full,
 237 -     "alias":alias,
 238 +     "full":quoteattr(full),
 239 +     "alias":quoteattr(alias),
 240       "exif_date":exif_date,
 241       "target":target,
 242 +     "pull_from_dir":pull_from_dir,
 243       "submit":submit,
 244       "thumbnail_width":thumbnail_width,
 245 -     "tools_html": show_tools_mode1(show_tools,pagename,this_image,thumbnail_width,full,alias,target,exif_date,request),  
 246 +     "tools_html": show_tools_mode1(show_tools,pagename,this_image,thumbnail_width,full,alias,target,exif_date,request,pull_from_dir),  
 247       "date_html":show_date_mode1(show_date,this_exif_date),
 248       "alias_html": show_alias_mode1(show_alias,thumbnail_width,this_alias,text_width)
 249       }
 250  
 251     return text
 252  
 253 -def get_files(kw,path,files,quotes,request):
 254 +def get_files(kw,path,files,quotes,request,tmp_prefix):
 255      web = []
 256      full = []
 257      thumb = []
 258 @@ -636,22 +670,21 @@
 259      source_type = ''
 260      for attfile in files:
 261          # only files not thumb or webnails
 262 -        if attfile.find('thumbnail_') == -1 and attfile.find('webnail_') == -1:
 263 +        if not os.path.split(attfile)[1].startswith('autogenerated-'):
 264              # only images
 265              if wikiutil.isPicture(attfile):
 266 -                description.append(ddict.get(attfile, attfile))
 267                  full.append(attfile)
 268                  
 269                  fname, ext = os.path.splitext(attfile)
 270                  if ext in ('.gif', '.png'):
 271                      img_type.append('PNG')
 272 -                    webnail = 'webnail_%s.png' % fname
 273 -                    thumbfile = 'thumbnail_%s.png' % fname
 274 +                    webnail = tmp_prefix + 'webnail_%s.png' % fname
 275 +                    thumbfile = tmp_prefix + 'thumbnail_%s.png' % fname
 276                      source_type = ext[1:]
 277                  else:
 278                      img_type.append("JPEG")
 279 -                    webnail = 'webnail_%s.jpg' % fname
 280 -                    thumbfile = 'thumbnail_%s.jpg' % fname
 281 +                    webnail = tmp_prefix + 'webnail_%s.jpg' % fname
 282 +                    thumbfile = tmp_prefix + 'thumbnail_%s.jpg' % fname
 283                      source_type = 'jpg'    
 284                  
 285                      
 286 @@ -668,6 +701,11 @@
 287                  else:
 288                      date = '--'
 289                  exif_date.append(date)
 290 +                #
 291 +                desc = ddict.get(attfile, attfile)
 292 +                if tags.has_key('EXIF UserComment'):
 293 +                    desc += " " + removeControlChar(str(tags['EXIF UserComment']))
 294 +                description.append(desc)
 295                  f.close() 
 296            
 297      return thumb,web,full,video_type, exif_date,img_type,source_type,description  
 298 @@ -747,6 +785,7 @@
 299              'thumbnail_width': '128',
 300              'webnail_width': '640',
 301              'text_width': '140',
 302 +            'pull_from_dir': '',
 303              'sequence_name' : '',
 304              'sequence_fps'  : '1',
 305              'eo_info' : '0',
 306 @@ -761,6 +800,7 @@
 307  
 308  
 309          self.kw['width']=str((int(self.kw['thumbnail_width'])+int(self.kw['text_width'])))
 310 +        self.tmp_prefix = "autogenerated-" + sha.new(os.path.abspath(self.kw['pull_from_dir'])).hexdigest() + "-" # prefix for generated files
 311  
 312  
 313      def format(self, formatter):
 314 @@ -768,7 +808,11 @@
 315          Dict = {}
 316          quotes=get_quotes(self,formatter)
 317          current_pagename=formatter.page.page_name
 318 -        attachment_path = AttachFile.getAttachDir(self.request, current_pagename, create=1)
 319 +        if kw['pull_from_dir']:
 320 +            attachment_path = kw['pull_from_dir']
 321 +        else:
 322 +            attachment_path = AttachFile.getAttachDir(self.request,current_pagename,create=1)
 323 +        out_path = AttachFile.getAttachDir(self.request,current_pagename,create=1)
 324   
 325          if kw['help'] == '1':
 326              self.request.write('''
 327 @@ -818,7 +862,13 @@
 328                  Dict.clear()
 329             
 330          else:
 331 -            all_files=os.listdir(attachment_path)
 332 +            try:
 333 +                all_files=os.listdir(attachment_path)
 334 +            except WindowsError, e:
 335 +                if e.errno == 3:
 336 +                    all_files = []
 337 +                else:
 338 +                    raise
 339  
 340          result = []
 341  
 342 @@ -828,7 +878,7 @@
 343          all_files=result
 344          
 345          if not all_files:
 346 -            self.request.write("<br><br><h1>No matching image file found!</h1>")
 347 +            self.request.write("<br><br><h1>No matching image file found in '%s'!</h1>" % attachment_path)
 348              return
 349  
 350          if kw['sort_by_name'] == '1' and kw['only_items'] == '0': 
 351 @@ -851,7 +901,7 @@
 352          if kw['reverse_sort'] == '1': 
 353               all_files.reverse()   
 354  
 355 -        thumb, web, full, video_type, exif_date, imgtype, source_type, description = get_files(kw, attachment_path, all_files, quotes, self.request)
 356 +        thumb, web, full, video_type, exif_date, imgtype, source_type, description = get_files(kw, attachment_path, all_files, quotes, self.request, self.tmp_prefix)
 357          
 358          if kw['template_itemlist'] == '1':
 359              self.request.write('Copy the following listitems into the script. Replace alias with the label you want. Afterwards disable template_itemlist by setting it to 0:<BR>')
 360 @@ -891,8 +941,8 @@
 361              this_webnail = web[i]
 362              this_imgtype = imgtype[i]
 363              this_thumbfile = thumb[i]
 364 -            thumbf = os.path.join(attachment_path,this_thumbfile)
 365 -            webf = os.path.join(attachment_path,this_webnail)            
 366 +            thumbf = os.path.join(out_path,this_thumbfile)
 367 +            webf = os.path.join(out_path,this_webnail)            
 368              
 369              if kw['renew'] == '1':
 370                  if os.path.exists(thumbf):
 371 @@ -909,11 +959,11 @@
 372                      if kw['image_for_webnail'] == '1' :
 373                         os.link(os.path.join(attachment_path,attfile),webf)
 374                      else:
 375 -                       im.save(webf, this_imgtype)
 376 +                       saveImageProgressiveIfPossible(im, webf, this_imgtype)
 377                  if not os.path.exists(thumbf):
 378                      im.thumbnail(((int(kw['thumbnail_width'])),((int(kw['thumbnail_width'])))),
 379                                     Image.ANTIALIAS)
 380 -                    im.save(thumbf, this_imgtype)       
 381 +                    saveImageProgressiveIfPossible(im, thumbf, this_imgtype)
 382                      
 383              if kw['image_for_webnail'] == '1' :     
 384                   this_webnailimg = attfile
 385 @@ -940,7 +990,8 @@
 386                          kw['show_tools'],
 387                          kw['show_date'],
 388                          kw['show_text'],
 389 -                        self.request
 390 +                        self.request,
 391 +                        kw['pull_from_dir'],
 392                          )
 393                  self.request.write(''.join(text))    
 394                          
 395 @@ -962,7 +1013,8 @@
 396                          kw['show_tools'],
 397                          kw['show_date'],
 398                          kw['show_text'],
 399 -                        self.request
 400 +                        self.request,
 401 +                        kw['pull_from_dir'],
 402                          )
 403              
 404                  if cols > 1 : self.request.write('<table valign="bottom">')
 405 @@ -1057,4 +1109,4 @@
 406                    
 407                  
 408          
 409 -       
 410 \ No newline at end of file
 411 +       
 412 --- C:\download\pmswiki\gallery2\gallery2image-1.5.1-12.py	2006-07-27 14:36:48.287780800 +0200
 413 +++ gallery2image.py	2006-07-27 14:36:48.297795200 +0200
 414 @@ -72,7 +72,10 @@
 415  from MoinMoin.action import AttachFile
 416  from MoinMoin.formatter.text_html import Formatter
 417  from MoinMoin.parser import wiki
 418 -
 419 +import pmsfile
 420 +import shutil
 421 +import subprocess
 422 +import sha
 423  
 424  def option_list(this_image,pagename,text,request):
 425      txt = ''
 426 @@ -401,6 +404,35 @@
 427  
 428  action_name = __name__.split('.')[-1]
 429  
 430 +
 431 +def quoteCommandArgument(a):
 432 +    if '"' in a:
 433 +        a = a.replace('"', '\\"')
 434 +    if '"' in a or ' ' in a:
 435 +        a = '"' + a + '"'       
 436 +    return a
 437 +    
 438 +def updateExifInformation(img_type, source, destination):
 439 +    if img_type != "JPEG":
 440 +        return True
 441 +    cmd = 'jhead -te %s -rgt 160 -norot %s' % (quoteCommandArgument(source), quoteCommandArgument(destination))
 442 +    exitcode = subprocess.Popen(cmd).wait()
 443 +    if exitcode == 0:
 444 +        return True
 445 +    return False
 446 +
 447 +def saveImageProgressiveIfPossible(im, filename, img_type):
 448 +    progressive = 0
 449 +    if img_type == "JPEG":
 450 +        progressive = 1
 451 +    try:
 452 +        im.save(filename, img_type, progressive=progressive)
 453 +    except IOError, e:
 454 +        if e.args[0] == 'encoder error -2 when writing image file':
 455 +            im.save(filename, img_type)
 456 +        else:
 457 +            raise
 458 +
 459  def execute(pagename, request):
 460      """ Main dispatcher for the 'Gallery' action.
 461      """
 462 @@ -413,7 +445,7 @@
 463          images = string.split(request.form['target'][0],',')
 464          target = images[0]
 465          images = (images[1:])
 466 -        
 467 +
 468          full_image = string.split(request.form['full'][0],',')
 469          full_target = full_image[0]
 470          full_image = (full_image[1:])
 471 @@ -482,19 +514,24 @@
 472  
 473          target=request.form['target'][0]
 474          file, ext = os.path.splitext(target)
 475 +        pull_from_dir = request.form['pull_from_dir'][0]
 476 +        tmp_prefix = "autogenerated-" + sha.new(os.path.abspath(pull_from_dir)).hexdigest() + "-" # prefix for generated files
 477  
 478          if ext == '.gif'  or  ext == '.png' :
 479              img_type = 'PNG'
 480 -            thumbfile = "thumbnail_%(file)s.png" % {"file" : file}
 481 -            webnail = "webnail_%(file)s.png" % {"file" : file}
 482 +            thumbfile = tmp_prefix + "thumbnail_%(file)s.png" % {"file" : file}
 483 +            webnail = tmp_prefix + "webnail_%(file)s.png" % {"file" : file}
 484          else:
 485              img_type="JPEG"
 486 -            thumbfile="thumbnail_%(file)s.jpg"  % {"file" : file}
 487 -            webnail="webnail_%(file)s.jpg"  % {"file" : file}
 488 +            thumbfile= tmp_prefix + "thumbnail_%(file)s.jpg"  % {"file" : file}
 489 +            webnail= tmp_prefix + "webnail_%(file)s.jpg"  % {"file" : file}
 490   
 491          thumb = os.path.join(attachment_path,thumbfile)
 492          webf = os.path.join(attachment_path,webnail)
 493 -        infile = os.path.join(attachment_path,target)
 494 +        if pull_from_dir:
 495 +            infile = os.path.join(pull_from_dir,target)
 496 +        else:
 497 +            infile = os.path.join(attachment_path,target)
 498  
 499          msg = None
 500          if version.release < '1.5.0' :
 501 @@ -504,8 +541,9 @@
 502          elif request.form['do'][0] == 'RM' :
 503              if os.path.exists(infile + '.bak') :
 504                 os.unlink("%(file)s.bak" % {"file" : infile})
 505 -            os.link(infile,"%(file)s.bak" % {"file" : infile})
 506 -            os.unlink(infile)
 507 +            #os.link(infile,"%(file)s.bak" % {"file" : infile})
 508 +            #os.unlink(infile)
 509 +            os.rename(infile,"%(file)s.bak" % {"file" : infile})
 510              os.unlink(webf)
 511              os.unlink(thumb)
 512              msg = _('%(target)s deleted, backup in place' % {
 513 @@ -514,31 +552,36 @@
 514          elif request.form['do'][0] == 'RL' :
 515              im = Image.open(infile)
 516              #os.unlink(infile)
 517 -            im.rotate(90).save(infile,img_type)
 518 +            tmpFilename = pmsfile.tempnam(extension=".jpeg")
 519 +            im.rotate(90).save(tmpFilename,img_type)
 520 +            if updateExifInformation(img_type, infile, tmpFilename):
 521 +                shutil.copyfile(tmpFilename, infile)
 522              nim = Image.open(infile)
 523              nim.thumbnail((640,640), Image.ANTIALIAS)
 524              #os.unlink(webf)
 525 -            nim.save(webf, img_type)
 526 +            saveImageProgressiveIfPossible(nim, webf, img_type)
 527              nim.thumbnail((128, 128), Image.ANTIALIAS)
 528              #os.unlink(thumb)
 529 -            nim.save(thumb, img_type)
 530 +            saveImageProgressiveIfPossible(nim, thumb, img_type)
 531              msg= _('%(target)s rotated to left 90 degrees' % {
 532 -                  'target':target})
 533 +                'target':target})
 534  
 535          elif request.form['do'][0] == 'RR' :
 536              im = Image.open(infile)
 537              #os.unlink(infile)
 538 -            im.rotate(270).save(infile,img_type)
 539 -            
 540 +            tmpFilename = pmsfile.tempnam(extension=".jpeg")
 541 +            im.rotate(270).save(tmpFilename,img_type)
 542 +            if updateExifInformation(img_type, infile, tmpFilename):
 543 +                shutil.copyfile(tmpFilename, infile)
 544              nim = Image.open(infile)
 545              nim.thumbnail((640,640), Image.ANTIALIAS)
 546              #os.unlink(webf)
 547              saveImageProgressiveIfPossible(nim, webf, img_type)
 548              nim.thumbnail((128, 128), Image.ANTIALIAS)
 549              #os.unlink(thumb)
 550 -            nim.save(thumb, img_type)
 551 +            saveImageProgressiveIfPossible(nim, thumb, img_type)
 552              msg= _('%(target)s rotated to right 90 degrees' % {
 553 -                  'target':target})
 554 +                'target':target})
 555               
 556          else:
 557              msg = _('action not implemented: %s') % (request.form['do'][0],)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-07-27 13:28:42, 41.0 KB) [[attachment:EXIF.py]]
  • [get | view] (2006-07-27 18:28:39, 2.8 KB) [[attachment:EXIF_patch.patch]]
  • [get | view] (2006-07-27 18:29:41, 50.5 KB) [[attachment:Gallery.patch]]
  • [get | view] (2006-07-27 19:15:39, 25.6 KB) [[attachment:Gallery2.patch]]
  • [get | view] (2006-07-27 13:33:03, 3175.6 KB) [[attachment:Gallery2_additional_files_win32.zip]]
  • [get | view] (2006-07-27 18:25:50, 4.5 KB) [[attachment:if_modified_since.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.