mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-07 13:25:24 +03:00
refactor out options
This commit is contained in:
parent
dd5bfec11c
commit
86bde427c3
|
@ -77,6 +77,7 @@ class Viewer(object):
|
||||||
# hook methods
|
# hook methods
|
||||||
|
|
||||||
format = None
|
format = None
|
||||||
|
options = {}
|
||||||
|
|
||||||
def get_format(self, image):
|
def get_format(self, image):
|
||||||
"""Return format name, or None to save as PGM/PPM"""
|
"""Return format name, or None to save as PGM/PPM"""
|
||||||
|
@ -87,7 +88,7 @@ class Viewer(object):
|
||||||
|
|
||||||
def save_image(self, image):
|
def save_image(self, image):
|
||||||
"""Save to temporary file, and return filename"""
|
"""Save to temporary file, and return filename"""
|
||||||
return image._dump(format=self.get_format(image), compress_level=1)
|
return image._dump(format=self.get_format(image), **self.options)
|
||||||
|
|
||||||
def show_image(self, image, **options):
|
def show_image(self, image, **options):
|
||||||
"""Display given image"""
|
"""Display given image"""
|
||||||
|
@ -116,6 +117,7 @@ elif sys.platform == "darwin":
|
||||||
|
|
||||||
class MacViewer(Viewer):
|
class MacViewer(Viewer):
|
||||||
format = "PNG"
|
format = "PNG"
|
||||||
|
options = {'compress-level': 1}
|
||||||
|
|
||||||
def get_command(self, file, **options):
|
def get_command(self, file, **options):
|
||||||
# on darwin open returns immediately resulting in the temp
|
# on darwin open returns immediately resulting in the temp
|
||||||
|
@ -143,6 +145,7 @@ else:
|
||||||
|
|
||||||
class UnixViewer(Viewer):
|
class UnixViewer(Viewer):
|
||||||
format = "PNG"
|
format = "PNG"
|
||||||
|
options = {'compress-level': 1}
|
||||||
|
|
||||||
def show_file(self, file, **options):
|
def show_file(self, file, **options):
|
||||||
command, executable = self.get_command_ex(file, **options)
|
command, executable = self.get_command_ex(file, **options)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user