Created
June 16, 2025 08:49
-
-
Save ilhan-athn7/e5ebadf8b38f4914eebf5ba8ac76a549 to your computer and use it in GitHub Desktop.
barcode_picture_remover
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import cv2 | |
from pyzbar.pyzbar import decode | |
folder_path = 'path/to/your/folder' | |
if not os.path.isdir(folder_path): | |
print(f"Folder not found: {folder_path}") | |
exit(1) | |
for filename in os.listdir(folder_path): | |
if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif')): | |
file_path = os.path.join(folder_path, filename) | |
image = cv2.imread(file_path) | |
if image is None: | |
print(f"Failed to read image: {filename}") | |
continue | |
barcodes = decode(image) | |
if barcodes: | |
print(f"Deleting {filename} — barcode detected") | |
os.remove(file_path) | |
else: | |
print(f"No barcode found in {filename}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment