mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	a new setting that allows you to skip thumbnail optimization.
This commit is contained in:
		| @@ -158,7 +158,12 @@ PAPERLESS_CONSUMPTION_DIR="../consume" | |||||||
|  |  | ||||||
| # When the consumer detects a duplicate document, it will not touch the | # When the consumer detects a duplicate document, it will not touch the | ||||||
| # original document. This default behavior can be changed here. | # original document. This default behavior can be changed here. | ||||||
| #PAPERLESS_CONSUMER_DELETE_DUPLICATES="false" | #PAPERLESS_CONSUMER_DELETE_DUPLICATES=false | ||||||
|  |  | ||||||
|  | # Use optipng to optimize thumbnails. This usually reduces the sice of | ||||||
|  | # thumbnails by about 20%, but uses considerable compute time during | ||||||
|  | # consumption. | ||||||
|  | #PAPERLESS_OPTIMIZE_THUMBNAILS=true | ||||||
|  |  | ||||||
| # After a document is consumed, Paperless can trigger an arbitrary script if | # After a document is consumed, Paperless can trigger an arbitrary script if | ||||||
| # you like.  This script will be passed a number of arguments for you to work | # you like.  This script will be passed a number of arguments for you to work | ||||||
|   | |||||||
| @@ -122,16 +122,19 @@ class DocumentParser(LoggingMixin): | |||||||
|  |  | ||||||
|     def optimise_thumbnail(self, in_path): |     def optimise_thumbnail(self, in_path): | ||||||
|  |  | ||||||
|         out_path = os.path.join(self.tempdir, "optipng.png") |         if settings.OPTIMIZE_THUMBNAILS: | ||||||
|  |             out_path = os.path.join(self.tempdir, "optipng.png") | ||||||
|  |  | ||||||
|         args = (settings.OPTIPNG_BINARY, "-silent", "-o5", in_path, "-out", out_path) |             args = (settings.OPTIPNG_BINARY, "-silent", "-o5", in_path, "-out", out_path) | ||||||
|  |  | ||||||
|         self.log('debug', 'Execute: ' + " ".join(args)) |             self.log('debug', 'Execute: ' + " ".join(args)) | ||||||
|  |  | ||||||
|         if not subprocess.Popen(args).wait() == 0: |             if not subprocess.Popen(args).wait() == 0: | ||||||
|             raise ParseError("Optipng failed at {}".format(args)) |                 raise ParseError("Optipng failed at {}".format(args)) | ||||||
|  |  | ||||||
|         return out_path |             return out_path | ||||||
|  |         else: | ||||||
|  |             return in_path | ||||||
|  |  | ||||||
|     def get_optimised_thumbnail(self): |     def get_optimised_thumbnail(self): | ||||||
|         return self.optimise_thumbnail(self.get_thumbnail()) |         return self.optimise_thumbnail(self.get_thumbnail()) | ||||||
|   | |||||||
| @@ -320,6 +320,8 @@ CONSUMER_POLLING = int(os.getenv("PAPERLESS_CONSUMER_POLLING", 0)) | |||||||
|  |  | ||||||
| CONSUMER_DELETE_DUPLICATES = __get_boolean("PAPERLESS_CONSUMER_DELETE_DUPLICATES") | CONSUMER_DELETE_DUPLICATES = __get_boolean("PAPERLESS_CONSUMER_DELETE_DUPLICATES") | ||||||
|  |  | ||||||
|  | OPTIMIZE_THUMBNAILS = __get_boolean("PAPERLESS_OPTIMIZE_THUMBNAILS", "true") | ||||||
|  |  | ||||||
| # The default language that tesseract will attempt to use when parsing | # The default language that tesseract will attempt to use when parsing | ||||||
| # documents.  It should be a 3-letter language code consistent with ISO 639. | # documents.  It should be a 3-letter language code consistent with ISO 639. | ||||||
| OCR_LANGUAGE = os.getenv("PAPERLESS_OCR_LANGUAGE", "eng") | OCR_LANGUAGE = os.getenv("PAPERLESS_OCR_LANGUAGE", "eng") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler