Every line of 'tkinter resize image' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
141 def resize(self, width, height, resample_algorithm=nearest, resize_canvas=True): 142 pixels = resample_algorithm.resize( 143 self, width, height, resize_canvas=resize_canvas 144 ) 145 return self._copy(pixels)
38 def image_resize(image, width = None, height = None, inter = cv2.INTER_AREA): 39 # ref: https://stackoverflow.com/questions/44650888/resize-an-image-without-distortion-opencv 40 41 # initialize the dimensions of the image to be resized and 42 # grab the image size 43 dim = None 44 (h, w) = image.shape[:2] 45 46 # if both the width and height are None, then return the 47 # original image 48 if width is None and height is None: 49 return image 50 51 # check to see if the width is None 52 if width is None: 53 # calculate the ratio of the height and construct the 54 # dimensions 55 r = height / float(h) 56 dim = (int(w * r), height) 57 58 # otherwise, the height is None 59 else: 60 # calculate the ratio of the width and construct the 61 # dimensions 62 r = width / float(w) 63 dim = (width, int(h * r)) 64 65 # resize the image 66 resized = cv2.resize(image, dim, interpolation = inter) 67 68 # return the resized image 69 return resized
26 def resize_image(image,w,h): 27 image=cv2.resize(image,(w,h)) 28 cv2.imwrite(Folder_name+"/Resize-"+str(w)+"*"+str(h)+Extension, image)
28 @curry 29 def resize(pil_img, size, interpolation=Image.BILINEAR): 30 return pil_img.resize(size, interpolation)
443 def resize(): 444 ax = applyScale2(frame_width, finalScale) 445 ay = applyScale2(frame_height, finalScale) 446 bx = int(ax / finalScale) 447 by = int(ay / finalScale) 448 im = Image.new("RGBA", (bx, by)) 449 im.paste(frame_image, (0, 0, frame_image.size[ 450 0], frame_image.size[1])) 451 frame_image = im.resize((ax, ay), Image.ANTIALIAS) 452 frame_image = frame_image.crop( 453 (0, 0, frame_size[0], frame_size[1]))
49 def _resize(frame): 50 """Resizing function utilizing OpenCV. 51 52 Args: 53 frame: A frame from a cv2.video_reader object to process 54 55 Returns: 56 resized_frame: the frame, resized 57 """ 58 resized_frame = cv2.resize(frame, 59 None, 60 fx=RESIZE_FACTOR, 61 fy=RESIZE_FACTOR, 62 interpolation=cv2.INTER_AREA) 63 64 return resized_frame
87 def RatioResize(self, image: Image.Image, maxWidth: int, maxHeight: int): 88 """Resize and return the provided image while maintaining aspect ratio.""" 89 90 ratio = max(maxWidth / image.width, maxHeight / image.height) 91 92 return image.resize( 93 (int(image.width * ratio), int(image.height * ratio)), Image.ANTIALIAS 94 )
48 def scale_image(self, image, scale): 49 50 if self.settings.opencv_or_pil == 'PIL': 51 ow, oh = image.size 52 nw = ow * scale 53 nh = oh * scale 54 return image.resize((int(nw), int(nh)), Image.ANTIALIAS) 55 56 else: 57 oh, ow, channels = image.shape 58 59 nw = ow * scale 60 nh = oh * scale 61 62 # PERF return cv2.resize(image, (int(nw), int(nh)), interpolation=cv2.INTER_NEAREST) 63 return cv2.resize(image, (int(nw), int(nh)), interpolation=cv2.INTER_CUBIC)
186 def resize(self, w, h, pil_image): 187 w_box = 200 188 h_box = 50 189 f1 = 1.0*w_box/w 190 f2 = 1.0*h_box/h 191 factor = min([f1, f2]) 192 width = int(w*factor) 193 height = int(h*factor) 194 return pil_image.resize((width, height), Image.ANTIALIAS)
28 def eff_resize(img, scale): 29 scale = float(scale) 30 return img.resize((int(img.size[0] * scale), int(img.size[1] * scale)), 31 Image.ANTIALIAS)