mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 10:37:12 -04:00 
			
		
		
		
	fix parse error of some documents by using gs
This commit is contained in:
		
							parent
							
								
									3db98faf5c
								
							
						
					
					
						commit
						0220199766
					
				| @ -45,13 +45,23 @@ class RasterisedDocumentParser(DocumentParser): | ||||
|         """ | ||||
| 
 | ||||
|         out_path = os.path.join(self.tempdir, "convert.png") | ||||
|         gs_out_path = os.path.join(self.tempdir, "gs_out.png") | ||||
| 
 | ||||
|         # Run convert to get a decent thumbnail | ||||
| 
 | ||||
|         # https://github.com/danielquinn/paperless/issues/447 | ||||
|         # call gs first | ||||
|         environment = os.environ.copy() | ||||
|         cmd = ["gs", "-q", "-sDEVICE=pngalpha", | ||||
|                "-o", gs_out_path, self.document_path] | ||||
|         if not subprocess.Popen(cmd, env=environment).wait() == 0: | ||||
|             raise ParseError("Thumbnail (gs) failed at {}".format(cmd)) | ||||
|         # then run convert on the output from gs | ||||
|         run_convert( | ||||
|             self.CONVERT, | ||||
|             "-scale", "500x5000", | ||||
|             "-alpha", "remove", | ||||
|             "{}[0]".format(self.document_path), | ||||
|             "gs_out_path", | ||||
|             out_path | ||||
|         ) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user