(self, fallback=True)
Return the matrix to convert pixel to mm space. If no matrix
        information is available and `fallback` is set to `True` then a matrix
        will be calculated from the size of the image.
Return the matrix to convert pixel to mm space. If no matrix
        information is available and `fallback` is set to `True` then a matrix
        will be calculated from the size of the image.
Return the matrix to convert pixel to mm space . If no matrix information is available and fallback is set to True then a matrix will be calculated from the size of the image .
def px_to_mm(self, fallback=True):
        """Return the matrix to convert pixel to mm space. If no matrix
        information is available and `fallback` is set to `True` then a matrix
        will be calculated from the size of the image."""
        if self.obj.raw_matrix is not None:
            return cairo.Matrix(*self.obj.raw_matrix)
        elif fallback:
            # Return a dummy matrix ... that maps the image to the page size
            width, height = self.obj.surface.get_size()
            xres, yres = image.get_tiff_resolution(
                self.obj.sheet.survey.path(self.obj.filename),
                self.obj.tiff_page)

            if xres == 0 or yres == 0:
                xres = width / self.obj.sheet.survey.defs.paper_width
                yres = height / self.obj.sheet.survey.defs.paper_height

            scan_width = width / xres
            scan_height = height / yres

            dx = (self.obj.sheet.survey.defs.paper_width - scan_width) / 2.0
            dy = (self.obj.sheet.survey.defs.paper_height - scan_height) / 2.0

            matrix = cairo.Matrix()

            # Center the image
            matrix.translate(dx, dy)
            matrix.scale(1.0 / xres, 1.0 / yres)

            return matrix
        else:
            return None
def px_to_mm ( self , fallback = True ) : if self . obj . raw_matrix is not None : return cairo . Matrix ( * self . obj . raw_matrix ) elif fallback : # Return a dummy matrix ... that maps the image to the page size width , height = self . obj . surface . get_size ( ) xres , yres = image . get_tiff_resolution ( self . obj . sheet . survey . path ( self . obj . filename ) , self . obj . tiff_page ) if xres == 0 or yres == 0 : xres = width / self . obj . sheet . survey . defs . paper_width yres = height / self . obj . sheet . survey . defs . paper_height scan_width = width / xres scan_height = height / yres dx = ( self . obj . sheet . survey . defs . paper_width - scan_width ) / 2.0 dy = ( self . obj . sheet . survey . defs . paper_height - scan_height ) / 2.0 matrix = cairo . Matrix ( ) # Center the image matrix . translate ( dx , dy ) matrix . scale ( 1.0 / xres , 1.0 / yres ) return matrix else : return None