Return raster resized by ratio.
439982
def _resize(self, ratio_x, ratio_y, resampling):
        """"""
        new_width = int(np.ceil(self.width * ratio_x))
        new_height = int(np.ceil(self.height * ratio_y))

        dest_affine = self.affine * Affine.scale(1 / ratio_x, 1 / ratio_y)
        if self.not_loaded():
            window = rasterio.windows.Window(0, 0, self.width, self.height)
            resized_raster = self.get_window(window, xsize=new_width, ysize=new_height, resampling=resampling)
        else:
            resized_raster = self._reproject(new_width, new_height, dest_affine, resampling=resampling)
        return resized_raster
570813
def resized(self, dl, targ, new_path, resume = True, fn=None):
        
        return dl.dataset.resize_imgs(targ, new_path, resume=resume, fn=fn) if dl else None
1159329
def pixel_to_size_ratio(self):
        
        left, right, _, _ = self.get_view_coordinates()
        width = right - left
        display_width = self.get_allocation().width
        return display_width / float(width)
655557
def get_image_ratio(self, image):
        
        x, y = self.get_image_size(image)
        return float(x) / y
1293115
function ratio(options) {
	const { width, height } = options;

	if ((width || height) && !(width && height)) {
		if (width) {
			options.height = width;
		}
		if (height) {
			options.width = height;
		}
	}

	return options;
}
165763
def _coarsenImage(image, f):
    '''
    
    '''
    from skimage.morphology import square
    from skimage.filters import rank
    from skimage.transform._warps import rescale
    selem = square(f)
    arri = rank.mean(image, selem=selem)
    return rescale(arri, 1 / f, order=0)
425847
def resize(self, size):
        """"""
        return Image(self.pil_image.resize(size, PIL.Image.ANTIALIAS))
477015
def preScale(self, sx, sy):
        """"""
        self.a *= sx
        self.b *= sx
        self.c *= sy
        self.d *= sy
        return self
366282
def _get_resize_target(img, crop_target, do_crop=False)->TensorImageSize:
    ""
    if crop_target is None: return None
    ch,r,c = img.shape
    target_r,target_c = crop_target
    ratio = (min if do_crop else max)(r/target_r, c/target_c)
    return ch,int(round(r/ratio)),int(round(c/ratio))
1065355
def get_size(item):
    """"""
    if isinstance(item, (list, set, tuple, dict)):
        return len(item)
    elif isinstance(item, (ndarray, MaskedArray)):
        return item.shape
    elif isinstance(item, Image):
        return item.size
    if isinstance(item, (DataFrame, Index, Series)):
        return item.shape
    else:
        return 1
1203874
def _get_dst_resolution(self, dst_res=None):
        """"""
        if dst_res is None:
            dst_res = min(self._res_indices.keys())
        return dst_res
373452
def resize(image, target_size, **kwargs):
    """"""

    if isinstance(target_size, int):
        target_size = (target_size, target_size)

    if not isinstance(target_size, (list, tuple, np.ndarray)):
        message = (
            "`target_size` should be a single number (width) or a list"
            "/tuple/ndarray (width, height), not {}.".format(type(target_size))
        )
        raise ValueError(message)

    rank = len(image.shape)
    assert 3 <= rank <= 4

    original_size = image.shape[-3:-1]

    if original_size == target_size:
        return image  # noop return because ndimage.zoom doesn't check itself

    # TODO: maybe allow -1 in target_size to signify aspect-ratio preserving resize?
    ratios = [t / o for t, o in zip(target_size, original_size)]
    zoom = [1] * rank
    zoom[-3:-1] = ratios

    roughly_resized = ndimage.zoom(image, zoom, **kwargs)
    return roughly_resized[..., : target_size[0], : target_size[1], :]
562080
def extent(self):
        """"""
        return (
            self.intervals[1].pix1 - 0.5,
            self.intervals[1].pix2 - 0.5,
            self.intervals[0].pix1 - 0.5,
            self.intervals[0].pix2 - 0.5,
        )
416258
def resize_image(image_str_tensor):
  """"""

  image = decode_and_resize(image_str_tensor)
  image = tf.image.encode_jpeg(image, quality=100)
  return image
799522
def get_resized_size(self):
        
        f = self.fmt
        iw, ih = self.image.size

        if not f.stretch and iw <= self.fw and ih <= self.fh:
            return

        if self.image_ratio == self.format_ratio:
            # same ratio, just resize
            return (self.fw, self.fh)

        elif self.image_ratio < self.format_ratio:
            # image taller than format
            return (self.fh * iw / ih, self.fh)

        else: # self.image_ratio > self.format_ratio
            # image wider than format
            return (self.fw, self.fw * ih / iw)
118789
def resize(self, ratio=None, ratio_x=None, ratio_y=None, dest_width=None, dest_height=None, dest_resolution=None,
               resampling=Resampling.cubic):
        
        # validate input:
        if sum([ratio is not None, ratio_x is not None and ratio_y is not None,
                dest_height is not None or dest_width is not None, dest_resolution is not None]) != 1:
            raise GeoRaster2Error(
                'please provide either ratio, or {ratio_x,ratio_y}, or {dest_height, dest_width}, or dest_resolution')

        if dest_width is not None and dest_height is not None:
            ratio_x = float(dest_width) / self.width
            ratio_y = float(dest_height) / self.height
        elif dest_width is not None:
            ratio = float(dest_width) / self.width
        elif dest_height is not None:
            ratio = float(dest_height) / self.height
        elif dest_resolution is not None:
            ratio = self.resolution() / dest_resolution
        if ratio is not None:
            ratio_x, ratio_y = ratio, ratio

        return self._resize(ratio_x, ratio_y, resampling)
1199012
def get_raster_array(image):
    
    if isinstance(image, RGB):
        rgb = image.rgb
        data = np.dstack([np.flipud(rgb.dimension_values(d, flat=False))
                          for d in rgb.vdims])
    else:
        data = image.dimension_values(2, flat=False)
        if type(image) is Raster:
            data = data.T
        else:
            data = np.flipud(data)
    return data