Exemplo n.º 1
0
 def test_get_image_info_invalid(self):
     expected = (u'Unknown filetype', 0, 0)
     result = image_tools.get_image_info(os.devnull)
     msg = ('get_image_info() on invalid image failed; '
            'result differs: %s:%dx%d instead of %s:%dx%d' %
            (result + expected))
     self.assertEqual(result, expected, msg=msg)
Exemplo n.º 2
0
 def test_get_image_info(self):
     for image in _TEST_IMAGES:
         image_path = get_image_path(image.name)
         expected = (image.format, ) + image.size
         result = image_tools.get_image_info(image_path)
         msg = ('get_image_info("%s") failed; '
                'result differs: %s:%dx%d instead of %s:%dx%d' %
                ((image.name, ) + result + expected))
         self.assertEqual(result, expected, msg=msg)
Exemplo n.º 3
0
 def test_get_image_info_invalid(self):
     expected = (u'Unknown filetype', 0, 0)
     result = image_tools.get_image_info(os.devnull)
     msg = (
         'get_image_info() on invalid image failed; '
         'result differs: %s:%dx%d instead of %s:%dx%d'
         % (result + expected)
     )
     self.assertEqual(result, expected, msg=msg)
Exemplo n.º 4
0
 def test_get_image_info(self):
     for image in _TEST_IMAGES:
         image_path = get_image_path(image.name)
         expected = (image.format,) + image.size
         result = image_tools.get_image_info(image_path)
         msg = (
             'get_image_info("%s") failed; '
             'result differs: %s:%dx%d instead of %s:%dx%d'
             % ((image.name,) + result + expected)
         )
         self.assertEqual(result, expected, msg=msg)
Exemplo n.º 5
0
    def get_mime_name(self, page=None):
        """Return a string with the name of the mime type of <page>. If
        <page> is None, return the mime type name of the current page.
        """
        self._wait_on_page(page)

        page_path = self.get_path_to_page(page)
        if page_path is None:
            return None

        format, dimensions, providers = image_tools.get_image_info(page_path)
        return format
Exemplo n.º 6
0
    def get_size(self, page=None):
        """Return a tuple (width, height) with the size of <page>. If <page>
        is None, return the size of the current page.
        """
        self._wait_on_page(page)

        page_path = self.get_path_to_page(page)
        if page_path is None:
            return (0, 0)

        format, dimensions, providers = image_tools.get_image_info(page_path)
        return dimensions
Exemplo n.º 7
0
    def get_mime_name(self, page=None):
        '''Return a string with the name of the mime type of <page>. If
        <page> is None, return the mime type name of the current page.
        '''
        self._wait_on_page(page)

        page_path = self.get_path_to_page(page)
        if page_path is None:
            return None

        format, width, height = image_tools.get_image_info(page_path)
        return format
Exemplo n.º 8
0
    def get_size(self, page=None):
        '''Return a tuple (width, height) with the size of <page>. If <page>
        is None, return the size of the current page.
        '''
        self._wait_on_page(page)

        page_path = self.get_path_to_page(page)
        if page_path is None:
            return (0, 0)

        format, width, height = image_tools.get_image_info(page_path)
        return (width, height)
Exemplo n.º 9
0
    def get_mime_name(self, page=None):
        """Return a string with the name of the mime type of <page>. If
        <page> is None, return the mime type name of the current page.
        """
        self._wait_on_page(page)

        page_path = self.get_path_to_page(page)
        if page_path is None:
            return None

        format, width, height = image_tools.get_image_info(page_path)
        return format
Exemplo n.º 10
0
    def get_size(self, page=None):
        """Return a tuple (width, height) with the size of <page>. If <page>
        is None, return the size of the current page.
        """
        self._wait_on_page(page)

        page_path = self.get_path_to_page(page)
        if page_path is None:
            return (0, 0)

        format, width, height = image_tools.get_image_info(page_path)
        return (width, height)
Exemplo n.º 11
0
 def _get_text_data(self, filepath):
     """ Creates a tEXt dictionary for <filepath>. """
     mime = mimetypes.guess_type(filepath)[0] or "unknown/mime"
     uri = portability.uri_prefix() + pathname2url(i18n.to_utf8(os.path.normpath(filepath)))
     stat = os.stat(filepath)
     # MTime could be floating point number, so convert to long first to have a fixed point number
     mtime = str(long(stat.st_mtime))
     size = str(stat.st_size)
     format, (width, height), providers = image_tools.get_image_info(filepath)
     return {
         'tEXt::Thumb::URI':           uri,
         'tEXt::Thumb::MTime':         mtime,
         'tEXt::Thumb::Size':          size,
         'tEXt::Thumb::Mimetype':      mime,
         'tEXt::Thumb::Image::Width':  str(width),
         'tEXt::Thumb::Image::Height': str(height),
         'tEXt::Software':             'MComix %s' % constants.VERSION
     }
Exemplo n.º 12
0
 def _get_text_data(self, filepath):
     """ Creates a tEXt dictionary for <filepath>. """
     mime = mimetypes.guess_type(filepath)[0] or "unknown/mime"
     uri = portability.uri_prefix() + pathname2url(i18n.to_utf8(os.path.normpath(filepath)))
     stat = os.stat(filepath)
     # MTime could be floating point number, so convert to long first to have a fixed point number
     mtime = str(long(stat.st_mtime))
     size = str(stat.st_size)
     format, width, height = image_tools.get_image_info(filepath)
     return {
         'tEXt::Thumb::URI':           uri,
         'tEXt::Thumb::MTime':         mtime,
         'tEXt::Thumb::Size':          size,
         'tEXt::Thumb::Mimetype':      mime,
         'tEXt::Thumb::Image::Width':  str(width),
         'tEXt::Thumb::Image::Height': str(height),
         'tEXt::Software':             'MComix %s' % constants.VERSION
     }