Skip to content

Commit aa7c2d6

Browse files
[Fix] ANTIALIAS fix
1 parent b853b1a commit aa7c2d6

6 files changed

Lines changed: 16 additions & 18 deletions

File tree

Apps/Windows/ZeuZ_Windows_Inspector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def showPIL(pilImage):
236236
ratio = min(w/imgWidth, h/imgHeight)
237237
imgWidth = int(imgWidth*ratio)
238238
imgHeight = int(imgHeight*ratio)
239-
pilImage = pilImage.resize((imgWidth,imgHeight), Image.ANTIALIAS)
239+
pilImage = pilImage.resize((imgWidth,imgHeight), Image.LANCZOS)
240240
image = ImageTk.PhotoImage(pilImage)
241241
imagesprite = canvas.create_image(w/2,h/2,image=image)
242242
root.mainloop()

Framework/Built_In_Automation/Built_In_Utility/CrossPlatform/BuiltInUtilityFunction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,7 +2258,7 @@ def TakeScreenShot(step_data):
22582258
size = 800, 450
22592259

22602260
im = Image.open(file1)
2261-
im.thumbnail(size, Image.ANTIALIAS)
2261+
im.thumbnail(size, Image.LANCZOS)
22622262
im.save(file2, "JPEG")
22632263
CommonUtil.ExecLog(
22642264
sModuleInfo, 'screenshot saved as: "%s"' % full_location, 1
@@ -2283,7 +2283,7 @@ def TakeScreenShot(step_data):
22832283
wpercent = basewidth / float(img.size[0])
22842284
hsize = int((float(img.size[1]) * float(wpercent)))
22852285
if img:
2286-
img = img.resize((basewidth, hsize), Image.ANTIALIAS)
2286+
img = img.resize((basewidth, hsize), Image.LANCZOS)
22872287
img.save(path, "JPEG")
22882288
CommonUtil.ExecLog(sModuleInfo, 'screenshot saved as: "%s"' % path, 1)
22892289
return "passed"

Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,6 @@ def new_image_text(step_data_set):
13431343

13441344
try:
13451345
from Framework import easyocr
1346-
import numpy as np
13471346
import cv2
13481347
from pytesseract import pytesseract
13491348
from difflib import SequenceMatcher
@@ -1363,7 +1362,7 @@ def new_image_text(step_data_set):
13631362
if mid == "element parameter":
13641363
if "index" in left:
13651364
idx = int(right.strip())
1366-
elif "ntext" in left:
1365+
elif "new_image_text" in left:
13671366
image_text = right
13681367
elif 'language' in left:
13691368
language = right
@@ -1406,11 +1405,10 @@ def seq(a, b):
14061405
if item == []:
14071406
CommonUtil.ExecLog(sModuleInfo, 'Could not find text "%s"' % image_text, 3)
14081407
return "zeuz_failed"
1409-
cord = np.array(item[idx][0])
1410-
cord1 = cord.tolist()
1411-
#
1412-
x_min, y_min = [min(cord_val) for cord_val in zip(*cord1[0])]
1413-
x_max, y_max = [max(cord_val) for cord_val in zip(*cord1[0])]
1408+
1409+
cords = item[idx][0][0]
1410+
x_min, y_min = cords[0][0], cords[0][1]
1411+
x_max, y_max = cords[2][0], cords[2][1]
14141412

14151413
if text_screenshot != '':
14161414
img = cv2.imread("sample.png")
@@ -1463,7 +1461,7 @@ def _scale_image(file_name, size_w, size_h):
14631461
size = (int(image_w * ratio), int(image_h * ratio)) # Calculate new resolution of image element
14641462

14651463
# Scale image
1466-
# file_name.thumbnail(size, Image.ANTIALIAS) # Resize image per calculation above
1464+
# file_name.thumbnail(size, Image.LANCZOS) # Resize image per calculation above
14671465

14681466
return file_name.resize(size) # Return the scaled image object
14691467
except:
@@ -1499,12 +1497,12 @@ def Get_Element(data_set, wait_time=Shared_Resources.Get_Shared_Variables("eleme
14991497
elif "automation" in left: element_automation = [right, _count_star(left)] # automationid
15001498
elif "control" in left: element_control = [right, _count_star(left)] # localizedcontroltype
15011499
elif "path" in left: element_path = right.strip()
1500+
elif "new_image_text" in left:
1501+
element_image.append((left, mid, right))
15021502
elif "image" in left:
15031503
element_image.append((left, mid, right))
15041504
elif "imagetext" in left:
15051505
element_image.append((left, mid, right))
1506-
elif "ntext" in left:
1507-
element_image.append((left, mid, right))
15081506

15091507

15101508
elif mid == "parent parameter":
@@ -1600,7 +1598,7 @@ def Get_Element(data_set, wait_time=Shared_Resources.Get_Shared_Variables("eleme
16001598
element_image.append(("t_screenshot", "element parameter", str(text_screenshot)))
16011599
element_image.append(("easyocr_paragraph", "element parameter", str(easyocr_paragraph)))
16021600

1603-
if 'ntext' in element_image[0][0]:
1601+
if 'new_image_text' in element_image[0][0]:
16041602
result = new_image_text(element_image)
16051603
return result
16061604
else:

Framework/Built_In_Automation/Shared_Resources/LocateElement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ def _scale_image(file_name, size_w, size_h):
13781378
size = (int(image_w * ratio), int(image_h * ratio)) # Calculate new resolution of image element
13791379

13801380
# Scale image
1381-
# file_name.thumbnail(size, Image.ANTIALIAS) # Resize image per calculation above
1381+
# file_name.thumbnail(size, Image.LANCZOS) # Resize image per calculation above
13821382

13831383
return file_name.resize(size) # Return the scaled image object
13841384
except:

Framework/Utilities/CommonUtil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ def Thread_ScreenShot(function_name, image_folder, Method, Driver, image_name):
909909
# Lower the picture quality
910910
if os.path.exists(ImageName): # Make sure image was saved
911911
image = Image.open(ImageName) # Re-open in standard format
912-
image.thumbnail(picture_size, Image.ANTIALIAS) # Resize picture to lower file size
912+
image.thumbnail(picture_size, Image.LANCZOS) # Resize picture to lower file size
913913
image.save(ImageName, format="PNG", quality=picture_quality) # Change quality to reduce file size
914914

915915
if debug_status:

Framework/easyocr/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@ def compute_ratio_and_resize(img,width,height,model_height):
571571
ratio = width/height
572572
if ratio<1.0:
573573
ratio = calculate_ratio(width,height)
574-
img = cv2.resize(img,(model_height,int(model_height*ratio)), interpolation=Image.ANTIALIAS)
574+
img = cv2.resize(img,(model_height,int(model_height*ratio)), interpolation=Image.LANCZOS)
575575
else:
576-
img = cv2.resize(img,(int(model_height*ratio),model_height),interpolation=Image.ANTIALIAS)
576+
img = cv2.resize(img,(int(model_height*ratio),model_height),interpolation=Image.LANCZOS)
577577
return img,ratio
578578

579579

0 commit comments

Comments
 (0)