本文整理汇总了Python中PythonMagick.Image.compressType方法的典型用法代码示例。如果您正苦于以下问题:Python Image.compressType方法的具体用法?Python Image.compressType怎么用?Python Image.compressType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonMagick.Image
的用法示例。
在下文中一共展示了Image.compressType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compress_tiff_files
# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import compressType [as 别名]
def compress_tiff_files(list_of_file_paths, destination_directory, delete_source=False):
"""
This method deals with compression of TIFF images. ZipCompression algorithm is used from the PythonMagick
library.
:param list_of_file_paths: ['C:\Users\gpatil\Desktop\image1.tiff', 'C:\Users\gpatilSample\image2.tiff']
:param destination_directory: 'C:\Users\gpatil\Desktop\image1.png'
:param delete_source: If the delete_source param is set to True then the original files will get
erased after they are compressed
:return: returns a dictionary containing the invalid file paths passed to the method (if any) and a result_code
that has the value 0 or 1 based on the success and failure of the operation
"""
result_dictionary = {}
invalid_files_list = []
for paths in list_of_file_paths:
if os.path.exists(paths) is False:
invalid_files_list.append(paths)
continue
image_object = Image(paths)
image_object.compressType(CompressionType.ZipCompression)
file_name = os.path.basename(paths)
print "Compressing Image" + str(file_name) + " to TIFF"
image_object.write(os.path.join(destination_directory, file_name))
print "Compression Complete"
if not invalid_files_list:
result_dictionary.update({"result_code": 0, "invalid_file_paths": "None"})
else:
csv_list_of_invalid_file_paths = ",".join(invalid_files_list)
result_dictionary.update({"result_code": -1, "invalid_file_paths": csv_list_of_invalid_file_paths})
print "Following files at paths could not be compressed"
for files in invalid_files_list:
print files
if delete_source is True:
for files in list_of_file_paths:
if os.path.exists(paths) is False:
invalid_files_list.append(paths)
continue
os.remove(files)
print "Legacy files deleted successfully"
return result_dictionary
开发者ID:gauravp19,项目名称:Python-TIFF-Convert-Compress-Rotate-Merge-using-IrfanView-and-PythonMagick,代码行数:41,代码来源:Operations-on-TIFF.py