def test_thumb_from_file_temp_partial(self):
        fn = NamedTemporaryFile()
        with open(self.filename, "rb") as h:
            fn.write(h.read(10))
        fn.flush()
        fn.seek(0, 0)

        thumb = thumbnails.get_thumbnail_from_file(fn, (50, 60))
        self.assertTrue(thumb is None)
        fn.close()
    def test_thumb_from_file_temp_partial(self):
        fn = NamedTemporaryFile()
        with open(self.filename, "rb") as h:
            fn.write(h.read(10))
        fn.flush()
        fn.seek(0, 0)

        thumb = thumbnails.get_thumbnail_from_file(fn, (50, 60))
        self.assertTrue(thumb is None)
        fn.close()
示例#3
0
    def get_pixbuf_many(self, songs, width, height):
        """Returns a Pixbuf which fits into the boundary defined by width
        and height or None.

        Uses the thumbnail cache if possible.
        """

        fileobj = self.get_cover_many(songs)
        if fileobj is None:
            return

        return get_thumbnail_from_file(fileobj, (width, height))
示例#4
0
    def get_pixbuf_many(self, songs, width, height):
        """Returns a Pixbuf which fits into the boundary defined by width
        and height or None.

        Uses the thumbnail cache if possible.
        """

        fileobj = self.get_cover_many(songs)
        if fileobj is None:
            return

        return get_thumbnail_from_file(fileobj, (width, height))
示例#5
0
    def _get_pixbuf(self):
        if not self._dirty:
            return self._pixbuf
        self._dirty = False

        max_size = 256 * self.get_scale_factor()

        self._pixbuf = None
        if self._file:
            self._pixbuf = thumbnails.get_thumbnail_from_file(
                self._file, (max_size, max_size))

        if not self._pixbuf:
            self._pixbuf = get_no_cover_pixbuf(max_size, max_size)

        return self._pixbuf
示例#6
0
文件: cover.py 项目: zsau/quodlibet
    def _get_pixbuf(self):
        if not self._dirty:
            return self._pixbuf
        self._dirty = False

        max_size = 256 * self.get_scale_factor()

        self._pixbuf = None
        if self._file:
            self._pixbuf = thumbnails.get_thumbnail_from_file(
                self._file, (max_size, max_size))

        if not self._pixbuf:
            self._pixbuf = get_no_cover_pixbuf(max_size, max_size)

        return self._pixbuf
    def _get_pixbuf(self):
        if not self._dirty:
            return self._pixbuf
        self._dirty = False

        self._pixbuf = None
        if self._file:
            try:
                self._pixbuf = thumbnails.get_thumbnail_from_file(
                    self._file, (256, 256))
            except GLib.GError:
                pass

        if not self._pixbuf:
            self._pixbuf = get_no_cover_pixbuf(256, 256)

        return self._pixbuf
示例#8
0
文件: cover.py 项目: ch1huizong/scode
    def _get_pixbuf(self):
        if not self._dirty:
            return self._pixbuf
        self._dirty = False

        max_size = 256 * get_scale_factor(self)

        self._pixbuf = None
        if self._file:
            try:
                self._pixbuf = thumbnails.get_thumbnail_from_file(
                    self._file, (max_size, max_size))
            except GLib.GError:
                pass

        if not self._pixbuf:
            self._pixbuf = get_no_cover_pixbuf(max_size, max_size)

        return self._pixbuf
 def test_thumb_from_file(self):
     with open(self.filename, "rb") as h:
         thumb = thumbnails.get_thumbnail_from_file(h, (50, 60))
         self.assertTrue(thumb)
 def test_thumb_from_file(self):
     with open(self.filename, "rb") as h:
         thumb = thumbnails.get_thumbnail_from_file(h, (50, 60))
         self.assertTrue(thumb)