Changeset 1129 in main


Ignore:
Timestamp:
05/28/12 13:14:06 (7 years ago)
Author:
pcosquer
Message:

new thumbnailer: files which contain a PNG thumbnail (like Google SketchUp? files)

Location:
trunk
Files:
1 added
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/docs/devel/modules/thumbnailers/thumbnailers_png.rst

    r1128 r1129  
    11============================================================================== 
    2 :mod:`thumbnailers.jfif` --- Thumbnailer for files containing a JPEG thumbnail 
     2:mod:`thumbnailers.png` --- Thumbnailer for files containing a PNG thumbnail 
    33============================================================================== 
    44 
    5 .. automodule:: plmapp.thumbnailers.jfifthumbnailer 
     5.. automodule:: plmapp.thumbnailers.pngthumbnailer 
    66    :members: 
    77    :show-inheritance: 
  • trunk/openPLM/plmapp/thumbnailers/__init__.py

    r1128 r1129  
    1818import magickthumbnailer 
    1919import jfifthumbnailer 
     20import pngthumbnailer 
    2021 
    2122from openPLM.plmapp.models import DocumentFile, thumbnailfs 
  • trunk/openPLM/plmapp/thumbnailers/jfifthumbnailer.py

    r1128 r1129  
    2020 
    2121All JPEG file starts with a magic number (``0xFFD8``). 
    22 This thumbnailer locates this magic number and try to read 
     22This thumbnailer locates this magic number and tries to read 
    2323the image with PIL. If it succeeds, it assumes it is the thumbnail. 
    24 If it fails, it try to find another magic number and retry. 
     24If it fails, it try to find another magic number and retries. 
    2525""" 
    2626 
     
    2929 
    3030from base import ThumbnailersManager 
     31from openPLM.plmapp.utils import SeekedFile 
    3132 
    32 class SeekedFile(object): 
    33     """ 
    34     A file-like object that wraps an already opened 
    35     and seeked file. 
    36  
    37     This file-like can be read by PIL and is used to  
    38     open an image contained in another file. 
    39     """ 
    40     def __init__(self, file): 
    41         self.shift = file.tell() 
    42         self.file = file   
    43     def read(self, *args): 
    44         return self.file.read(*args) 
    45  
    46     def readline(self, *args): 
    47         return self.file.readline(*args) 
    48  
    49     def readlines(self, *args): 
    50         return self.file.readlines(*args) 
    51  
    52     def tell(self): 
    53         return self.file.tell() - self.shift 
    54     def seek(self, offset, whence=0): 
    55         return self.file.seek(offset + self.shift, whence) 
    5633 
    5734def jfif_thumbnailer(input_path, original_filename, output_path): 
  • trunk/openPLM/plmapp/utils.py

    r1128 r1129  
    3232import os.path 
    3333from functools import wraps 
     34 
     35class SeekedFile(object): 
     36    """ 
     37    .. versionadded:: 1.1 
     38 
     39    A file-like object that wraps an already opened 
     40    and seeked file. 
     41 
     42    This file-like can be read by PIL and is used to  
     43    open an image contained in another file. 
     44    """ 
     45    def __init__(self, file): 
     46        self.shift = file.tell() 
     47        self.file = file   
     48     
     49    def read(self, *args): 
     50        return self.file.read(*args) 
     51 
     52    def readline(self, *args): 
     53        return self.file.readline(*args) 
     54 
     55    def readlines(self, *args): 
     56        return self.file.readlines(*args) 
     57 
     58    def tell(self): 
     59        return self.file.tell() - self.shift 
     60     
     61    def seek(self, offset, whence=0): 
     62        return self.file.seek(offset + self.shift, whence) 
     63 
    3464 
    3565def next_in_seq(seq, value): 
Note: See TracChangeset for help on using the changeset viewer.