mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +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,17 +4,7 @@ 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()
|
|
||||||
|
|
||||||
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()
|
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)
|
||||||
|
|
|
@ -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,6 +47,7 @@ def test_parser():
|
||||||
assert_image_equal(*roundtrip("TGA"))
|
assert_image_equal(*roundtrip("TGA"))
|
||||||
assert_image_equal(*roundtrip("PCX"))
|
assert_image_equal(*roundtrip("PCX"))
|
||||||
|
|
||||||
|
if EpsImagePlugin.has_ghostscript():
|
||||||
im1, im2 = roundtrip("EPS")
|
im1, im2 = roundtrip("EPS")
|
||||||
assert_image_similar(im1, im2.convert('L'),20) # EPS comes back in RGB
|
assert_image_similar(im1, im2.convert('L'),20) # EPS comes back in RGB
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user