def get_thumbnail(cls, path): """compress screenshot""" new_path = cls.get_small_name(path) if not os.path.isfile(new_path): try: img = Image.open(path) compress_image(img, new_path, ST.SNAPSHOT_QUALITY, max_size=300) except Exception: LOGGING.error(traceback.format_exc()) return new_path else: return None
def get_thumbnail(cls, path): """compress screenshot""" new_path = cls.get_small_name(path) if not os.path.isfile(new_path): try: img = Image.open(path) compress_image(img, new_path, ST.SNAPSHOT_QUALITY) except Exception: traceback.print_exc() return new_path else: return None
def imwrite(filename, img, quality=10): """写出图片到本地路径,压缩""" if PY2: filename = filename.encode(sys.getfilesystemencoding()) pil_img = cv2_2_pil(img) compress_image(pil_img, filename, quality, 1200, 1200)