mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
made has_ghostscript a method, using it from test_imagefile
This commit is contained in:
parent
52189030b8
commit
82d7524add
|
@ -50,6 +50,21 @@ if sys.platform.startswith('win'):
|
||||||
else:
|
else:
|
||||||
gs_windows_binary = False
|
gs_windows_binary = False
|
||||||
|
|
||||||
|
def has_ghostscript():
|
||||||
|
if gs_windows_binary:
|
||||||
|
return True
|
||||||
|
if not sys.platform.startswith('win'):
|
||||||
|
import subprocess
|
||||||
|
try:
|
||||||
|
gs = subprocess.Popen(['gs','--version'], stdout=subprocess.PIPE)
|
||||||
|
gs.stdout.read()
|
||||||
|
return True
|
||||||
|
except OSError:
|
||||||
|
# no ghostscript
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def Ghostscript(tile, size, fp, scale=1):
|
def Ghostscript(tile, size, fp, scale=1):
|
||||||
"""Render an image using Ghostscript"""
|
"""Render an image using Ghostscript"""
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,9 @@ from PIL import Image, EpsImagePlugin
|
||||||
import sys
|
import sys
|
||||||
import io
|
import io
|
||||||
|
|
||||||
if not EpsImagePlugin.gs_windows_binary:
|
if not EpsImagePlugin.has_ghostscript():
|
||||||
# already checked. Not there.
|
|
||||||
skip()
|
skip()
|
||||||
|
|
||||||
if not sys.platform.startswith('win'):
|
|
||||||
import subprocess
|
|
||||||
try:
|
|
||||||
gs = subprocess.Popen(['gs','--version'], stdout=subprocess.PIPE)
|
|
||||||
gs.stdout.read()
|
|
||||||
except OSError:
|
|
||||||
# no ghostscript
|
|
||||||
skip()
|
|
||||||
|
|
||||||
#Our two EPS test files (they are identical except for their bounding boxes)
|
#Our two EPS test files (they are identical except for their bounding boxes)
|
||||||
file1 = "Tests/images/zero_bb.eps"
|
file1 = "Tests/images/zero_bb.eps"
|
||||||
file2 = "Tests/images/non_zero_bb.eps"
|
file2 = "Tests/images/non_zero_bb.eps"
|
||||||
|
|
|
@ -2,6 +2,7 @@ from tester import *
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import ImageFile
|
from PIL import ImageFile
|
||||||
|
from PIL import EpsImagePlugin
|
||||||
|
|
||||||
codecs = dir(Image.core)
|
codecs = dir(Image.core)
|
||||||
|
|
||||||
|
@ -46,8 +47,9 @@ def test_parser():
|
||||||
assert_image_equal(*roundtrip("TGA"))
|
assert_image_equal(*roundtrip("TGA"))
|
||||||
assert_image_equal(*roundtrip("PCX"))
|
assert_image_equal(*roundtrip("PCX"))
|
||||||
|
|
||||||
im1, im2 = roundtrip("EPS")
|
if EpsImagePlugin.has_ghostscript():
|
||||||
assert_image_similar(im1, im2.convert('L'),20) # EPS comes back in RGB
|
im1, im2 = roundtrip("EPS")
|
||||||
|
assert_image_similar(im1, im2.convert('L'),20) # EPS comes back in RGB
|
||||||
|
|
||||||
if "jpeg_encoder" in codecs:
|
if "jpeg_encoder" in codecs:
|
||||||
im1, im2 = roundtrip("JPEG") # lossy compression
|
im1, im2 = roundtrip("JPEG") # lossy compression
|
||||||
|
|
Loading…
Reference in New Issue
Block a user