Enlarge or shrink a single image to scale, such that the smaller of the height or width dimension is equal to targ.
518015
def resize_img(fname, targ, path, new_path, fn=None):
    
    if fn is None:
        fn = resize_fn(targ)
    dest = os.path.join(path_for(path, new_path, targ), fname)
    if os.path.exists(dest): return
    im = Image.open(os.path.join(path, fname)).convert('RGB')
    os.makedirs(os.path.split(dest)[0], exist_ok=True)
    fn(im).save(dest)
500793
function resample(image, width, height) {
    let factor

    if (!width && !height) {
        width = image.width
        height = image.height
    }

    if (!width) {
        factor = height / image.height
        width = Math.round(image.width * factor)
    }

    if(!height) {
        factor = width / image.width
        height = Math.round(image.height * factor)
    }

    let canvas = image
    while(canvas.width > width && canvas.width * 0.5 > width) {
        canvas = scalingHelper(canvas, 0.5)
    }

    let finalCanvas = document.createElement('canvas')
    finalCanvas.width = width // 原始宽
    finalCanvas.height = height
    let ctx = finalCanvas.getContext('2d')
    ctx.drawImage(canvas, 0, 0, width, height)

    return finalCanvas
}
171060
public static <T extends ImageGray<T>>
	void scaleImageUp(T input , T output , int scale, InterpolatePixelS<T> interp ) {
		if( scale <= 1 )
			throw new IllegalArgumentException("Scale must be >= 2");
		if( input instanceof GrayF32) {
			ImplPyramidOps.scaleImageUp((GrayF32)input,(GrayF32)output,scale,(InterpolatePixelS)interp);
		} else if( input instanceof GrayU8) {
			ImplPyramidOps.scaleImageUp((GrayU8)input,(GrayU8)output,scale,(InterpolatePixelS)interp);
		} else {
			throw new IllegalArgumentException("Image type not yet supported");
		}
	}
590467
def resize(self, newWidth = 0, newHeight = 0):
        
        self.height = newHeight
        self.width = newWidth
476697
def resize(self, size):
        
        if isinstance(self._data, Stream):
            self._data.resize(size)
501266
def resize(self, width, height):
        
        if self.example:
            self.example.resize(width, height)
1026007
def reduce_to_image(dimensions)
      {
        width: [dimensions[:width], image_file_width].min,
        height: [dimensions[:height], image_file_height].min
      }
    end
1360304
public static Image scale(Image srcImage, int width, int height, Color fixedColor) {
		return Img.from(srcImage).scale(width, height, fixedColor).getImg();
	}
496362
def resize(self, size:Union[int,TensorImageSize]) -> 'ImagePoints':
        ""
        if isinstance(size, int): size=(1, size, size)
        self._flow.size = size[1:]
        return self
925429
def _scale(self, resource):
        
        original_width, original_height = resource.size

        target_width = int(round(original_width * self.value))
        target_height = int(round(original_height * self.value))

        resource_format = resource.format
        resource = resource.resize((target_width, target_height), Image.ANTIALIAS)
        resource.format = resource_format

        return resource
1114963
def shrink(self, src, width=0, path=None, flags=0):
        
        self.shrink_method(self, src, width, path, flags)
1271364
def __execute_scale(self, surface, size_to_scale_from):
        """"""
        x = size_to_scale_from[0] * self.__scale[0]
        y = size_to_scale_from[1] * self.__scale[1]
        scaled_value = (int(x), int(y))

##        #Find out what scaling technique we should use.
##        if self.image.get_bitsize >= 24:
##            #We have sufficient bit depth to run smooth scale
##            self.image = pygame.transform.smoothscale(self.image, scaled_value)
##        else:
            ##Surface doesn't support smooth scale, revert to regular scale
        self.image = pygame.transform.scale(self.image, scaled_value)

        self.__resize_surface_extents()
627944
def scale(self, dx=1.0, dy=1.0):
        '''
        

        '''
        self.width *= dx
        self.height *= dy
708172
def conditional_resize(image, ratio, width=None, height=None, upcrop=True,
                       namespace="resized"):
    
    aspect = float(image.width) / float(image.height)
    crop = False

    if (aspect > ratio and upcrop) or (aspect <= ratio and not upcrop):
        crop = True

    return resize_lazy(image=image, width=width, height=height, crop=crop,
                       namespace=namespace, as_url=True)
1163317
public static void reshapeDown(ImageBase image, int inputWidth, int inputHeight, int squareWidth) {
		int w = downSampleSize(inputWidth,squareWidth);
		int h = downSampleSize(inputHeight,squareWidth);

		image.reshape(w,h);
	}
637580
def scale_image(image, new_width):
    
    (original_width, original_height) = image.size
    aspect_ratio = original_height/float(original_width)
    new_height = int(aspect_ratio * new_width)

    # This scales it wider than tall, since characters are biased
    new_image = image.resize((new_width*2, new_height))
    return new_image
356969
def resize(self, size:Union[int,TensorImageSize])->'Image':
        ""
        assert self._flow is None
        if isinstance(size, int): size=(self.shape[0], size, size)
        if tuple(size)==tuple(self.shape): return self
        self.flow = _affine_grid(size)
        return self