mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-16 21:55:37 -05:00
Feature: support barcode upscaling for better detection of small barcodes (#3655)
This commit is contained in:
@@ -203,11 +203,21 @@ class BarcodeReader:
|
||||
try:
|
||||
pages_from_path = convert_from_path(
|
||||
self.pdf_file,
|
||||
dpi=300,
|
||||
dpi=settings.CONSUMER_BARCODE_DPI,
|
||||
output_folder=self.temp_dir.name,
|
||||
)
|
||||
|
||||
for current_page_number, page in enumerate(pages_from_path):
|
||||
factor = settings.CONSUMER_BARCODE_UPSCALE
|
||||
if factor > 1.0:
|
||||
logger.debug(
|
||||
f"Upscaling image by {factor} for better barcode detection",
|
||||
)
|
||||
x, y = page.size
|
||||
page = page.resize(
|
||||
(int(round(x * factor)), (int(round(y * factor)))),
|
||||
)
|
||||
|
||||
for barcode_value in reader(page):
|
||||
self.barcodes.append(
|
||||
Barcode(current_page_number, barcode_value),
|
||||
|
Reference in New Issue
Block a user