mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-15 06:07:33 +03:00
use "with Image" instead of closing manually
This commit is contained in:
parent
3ccecd91ce
commit
00bbd4a5b9
|
@ -157,8 +157,9 @@ def Ghostscript(
|
||||||
startupinfo = subprocess.STARTUPINFO()
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
subprocess.check_call(command, startupinfo=startupinfo)
|
subprocess.check_call(command, startupinfo=startupinfo)
|
||||||
out_im = Image.open(outfile)
|
with Image.open(outfile) as out_im:
|
||||||
out_im.load()
|
out_im.load()
|
||||||
|
return out_im.im.copy()
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
os.unlink(outfile)
|
os.unlink(outfile)
|
||||||
|
@ -167,10 +168,6 @@ def Ghostscript(
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
im = out_im.im.copy()
|
|
||||||
out_im.close()
|
|
||||||
return im
|
|
||||||
|
|
||||||
|
|
||||||
def _accept(prefix: bytes) -> bool:
|
def _accept(prefix: bytes) -> bool:
|
||||||
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
|
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user