r"""(:class:`~typing.Optional`\ [:class:`~typing.Tuple`\ [:class:`int`,
        :class:`int`]]) The (width, height) pair of the image.
        It may be :const:`None` if it's not an image.
331500
def image_resolution(self) -> Optional[Tuple[int, int]]:
        

        """
        images = self.attributes.get('imageinfo', [])
        if images and isinstance(images, collections.abc.Sequence):
            img = images[0]
            return img['width'], img['height']
        return None
104954
def _get_size(self) -> Tuple[int, int]:
        
        w = ffi.new("int *")
        h = ffi.new("int *")
        lib.TCOD_image_get_size(self.image_c, w, h)
        return w[0], h[0]
785699
def tenengrad(img, ksize=3):
    '''''''
    Gx = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=1, dy=0, ksize=ksize)
    Gy = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=0, dy=1, ksize=ksize)
    FM = Gx*Gx + Gy*Gy
    mn = cv2.mean(FM)[0]
    if np.isnan(mn):
        return np.nanmean(FM)
    return mn
188271
def _parse(self, data):
        
        super(Image, self)._parse(data)
        self.height = data['height']
        self.type = data['type']
        self.width = data['width']
48068
def _image_attrs(self, attrs):
        

        path = None
        config = {**self._config}

        for key, val in attrs:
            if key.lower() == 'width' or key.lower() == 'height':
                try:
                    config[key.lower()] = int(val)
                except ValueError:
                    pass
            elif key.lower() == 'src':
                path = val

        img_path, img_args, _ = image.parse_image_spec(path)
        img = image.get_image(img_path, self._search_path)

        for key, val in img_args.items():
            if val and key not in config:
                config[key] = val

        try:
            img_attrs = img.get_img_attrs(**config)
        except FileNotFoundError as error:
            return [('data-publ-error', 'file not found: {}'.format(error.filename))]

        # return the original attr list with the computed overrides in place
        return [(key, val) for key, val in attrs
                if key.lower() not in img_attrs] + list(img_attrs.items())
905689
def norm_shape(shape):
    '''
    
    '''
    try:
        i = int(shape)
        return (i,)
    except TypeError:
        # shape was not a number
        pass
 
    try:
        t = tuple(shape)
        return t
    except TypeError:
        # shape was not iterable
        pass
     
    raise TypeError('shape must be an int, or a tuple of ints')
399560
def _parse_example_spec(self):
    """"""
    height, width = image_util.get_expected_image_size(self.module_spec)
    input_shape = [height, width, 3]
    return {self.key: tf_v1.FixedLenFeature(input_shape, tf.float32)}
826074
def get_tuple(self):
        """"""
        objType, objInstance = self.value

        if isinstance(objType, int):
            pass
        elif isinstance(objType, str):
            # turn it back into an integer
            objType = self.objectTypeClass()[objType]
        else:
            raise TypeError("invalid datatype for objType")

        # pack the components together
        return (objType, objInstance)
317784
def img_box(img, box):
    
    if isinstance(box, tuple):
        box = Box.from_tup(box)

    if len(img.shape) == 3:
        return img[box.y:box.y + box.height, box.x:box.x + box.width, :]
    else:
        return img[box.y:box.y + box.height, box.x:box.x + box.width]
341422
def rounded(self, image, geometry, options):
        
        r = options['rounded']
        if not r:
            return image
        return self._rounded(image, int(r))
845747
def get_image(roi_rec, short, max_size, mean, std):
    
    im = imdecode(roi_rec['image'])
    if roi_rec["flipped"]:
        im = im[:, ::-1, :]
    im, im_scale = resize(im, short, max_size)
    height, width = im.shape[:2]
    im_info = np.array([height, width, im_scale], dtype=np.float32)
    im_tensor = transform(im, mean, std)

    # gt boxes: (x1, y1, x2, y2, cls)
    if roi_rec['gt_classes'].size > 0:
        gt_inds = np.where(roi_rec['gt_classes'] != 0)[0]
        gt_boxes = np.empty((len(gt_inds), 5), dtype=np.float32)
        gt_boxes[:, 0:4] = roi_rec['boxes'][gt_inds, :]
        gt_boxes[:, 4] = roi_rec['gt_classes'][gt_inds]
        # scale gt_boxes
        gt_boxes[:, 0:4] *= im_scale
    else:
        gt_boxes = np.empty((0, 5), dtype=np.float32)

    return im_tensor, im_info, gt_boxes
1128329
def shape(self):
        
        ndim = mx_int()
        pdata = ctypes.POINTER(mx_int)()
        check_call(_LIB.MXNDArrayGetShapeEx(
            self.handle, ctypes.byref(ndim), ctypes.byref(pdata)))
        if ndim.value == -1:
            return None
        else:
            return tuple(pdata[:ndim.value])
255150
def image_size(self) -> Optional[int]:
        

        """
        images = self.attributes.get('imageinfo', [])
        if images and isinstance(images, collections.abc.Sequence):
            return images[0]['size']
        return None
383926
def dimensional_shape(self) -> typing.Optional[typing.Tuple[int, ...]]:
        """"""
        if not self.__data_and_metadata:
            return None
        return self.__data_and_metadata.dimensional_shape
1227565
def image(self):
        
        image_id = self.attrs.get('ImageID', self.attrs['Image'])
        if image_id is None:
            return None
        return self.client.images.get(image_id.split(':')[1])
102517
function (src, x, y, width, height) {
		var obj = this.createElement('img')
			.attr({ src: src });

		if (arguments.length > 1) {
			obj.attr({
				x: x,
				y: y,
				width: width,
				height: height
			});
		}
		return obj;
	}
1265497
def getDimensionForImage(filename, maxsize):
    """"""
    try:
        from PIL import Image
    except ImportError:
        return None
    img = Image.open(filename)
    width, height = img.size
    if width > maxsize[0] or height > maxsize[1]:
        img.thumbnail(maxsize)
        out.info("Downscaled display size from %s to %s" % ((width, height), img.size))
    return img.size