mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Fix Ghostscript command on Windows
This commit is contained in:
		
							parent
							
								
									5c9c5e45fd
								
							
						
					
					
						commit
						de17144f6b
					
				| 
						 | 
					@ -33,8 +33,25 @@ o32 = _binary.o32le
 | 
				
			||||||
split = re.compile(r"^%%([^:]*):[ \t]*(.*)[ \t]*$")
 | 
					split = re.compile(r"^%%([^:]*):[ \t]*(.*)[ \t]*$")
 | 
				
			||||||
field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$")
 | 
					field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					gs_windows_binary = None
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					if sys.platform[:3].lower() == 'win':
 | 
				
			||||||
 | 
					    import shutil
 | 
				
			||||||
 | 
					    if hasattr(shutil, 'which'):
 | 
				
			||||||
 | 
					        which = shutil.which
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        # Python < 3.3
 | 
				
			||||||
 | 
					        import distutils
 | 
				
			||||||
 | 
					        which = distutils.spawn.find_executable
 | 
				
			||||||
 | 
					    for binary in ('gswin32c', 'gswin64c', 'gs'):
 | 
				
			||||||
 | 
					        if which(binary) is not None:
 | 
				
			||||||
 | 
					            gs_windows_binary = binary
 | 
				
			||||||
 | 
					            break
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        gs_windows_binary = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def Ghostscript(tile, size, fp):
 | 
					def Ghostscript(tile, size, fp):
 | 
				
			||||||
    """Render an image using Ghostscript (Unix only)"""
 | 
					    """Render an image using Ghostscript"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Unpack decoder tile
 | 
					    # Unpack decoder tile
 | 
				
			||||||
    decoder, tile, offset, data = tile[0]
 | 
					    decoder, tile, offset, data = tile[0]
 | 
				
			||||||
| 
						 | 
					@ -53,6 +70,12 @@ def Ghostscript(tile, size, fp):
 | 
				
			||||||
               "-sOutputFile=%s" % file,# output file
 | 
					               "-sOutputFile=%s" % file,# output file
 | 
				
			||||||
               "- >/dev/null 2>/dev/null"]
 | 
					               "- >/dev/null 2>/dev/null"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if gs_windows_binary is not None:
 | 
				
			||||||
 | 
					        if gs_windows_binary is False:
 | 
				
			||||||
 | 
					            raise WindowsError('Unable to locate Ghostscript on paths')
 | 
				
			||||||
 | 
					        command[0] = gs_windows_binary
 | 
				
			||||||
 | 
					        command[-1] = '- >nul 2>nul'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    command = " ".join(command)
 | 
					    command = " ".join(command)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # push data through ghostscript
 | 
					    # push data through ghostscript
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user