Logo Search packages:      
Sourcecode: rapid-photo-downloader version File versions  Download package

def rapid::media::MediaFile::generateThumbnail (   self,
  tempWorkingDir 
)

Attempts to generate or extract a thumnail and its orientation for the photo or video

Definition at line 191 of file media.py.

00191                                                :
        """
        Attempts to generate or extract a thumnail and its orientation for the photo or video
        """
        if self.metadata is None:
            sys.stderr.write("metadata should not be empty!")
        else:
            if self.isImage:
                try:
                    thumbnail = self.metadata.getThumbnailData(MAX_THUMBNAIL_SIZE)
                    if not isinstance(thumbnail, types.StringType):
                        self.thumbnail = None
                    else:
                        orientation = self.metadata.orientation(missing=None)
                        pbloader = gtk.gdk.PixbufLoader()
                        pbloader.write(thumbnail)
                        pbloader.close()
                        # Get the resulting pixbuf and build an image to be displayed
                        pixbuf = pbloader.get_pixbuf()
                        if orientation == 8:
                            pixbuf = pixbuf.rotate_simple(gtk.gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE)
                        elif orientation == 6:
                            pixbuf = pixbuf.rotate_simple(gtk.gdk.PIXBUF_ROTATE_CLOCKWISE)
                        elif orientation == 3:
                            pixbuf = pixbuf.rotate_simple(gtk.gdk.PIXBUF_ROTATE_UPSIDEDOWN)
                        
                        self.thumbnail = pixbuf
                except:
                    pass
            else:
                # get thumbnail of video
                # it may need to be generated
                self.thumbnail = self.metadata.getThumbnailData(MAX_THUMBNAIL_SIZE, tempWorkingDir)
        if self.thumbnail:
            # scale to size
            self.thumbnail = common.scale2pixbuf(MAX_THUMBNAIL_SIZE, MAX_THUMBNAIL_SIZE, self.thumbnail)

    

class Media:


Generated by  Doxygen 1.6.0   Back to index