-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to do Duplex Scanning #70
Comments
I am using Ubuntu 18.4 LTS , Python 2.7 |
iter = sane._SaneIterator(dev) Its working now as iterator class was not used ... Another question is how can we save the images during Next() within while loop are add them in an array but how can we identify Front and Back side of the scanned images please? |
Hi , did u find any solution ? |
i am unable to perform duplex scanning with below code, kindly help me here. Below is my code. import os
from PIL import Image
import sane
# Initialize sane
ver = sane.init()
print('SANE version:', ver)
# Get devices
devices = sane.get_devices()
print('Available devices:', devices)
# Open first device
dev = sane.open(devices[0][0])
try:
dev.br_x = 320.
dev.br_y = 240.
except:
print('Cannot set scan area, using default')
params = dev.get_parameters()
print('Device parameters:', params)
# Create a directory to store scanned images
output_dir = "scanned_images"
os.makedirs(output_dir, exist_ok=True)
# Start scanning
images_list = []
try:
# Perform scanning operation
images = dev.multi_scan()
print('Scanning documents')
# Save each scanned image to a separate file
for i, image in enumerate(images):
output_filename = os.path.join(output_dir, f"page_{i + 1}.png")
# Convert the image to PIL Image object
pil_image = Image.frombytes('RGB', image.size, image.tobytes())
# Rotate the image
pil_image = pil_image.rotate(180)
# Save the image
pil_image.save(output_filename)
images_list.append(output_filename)
print(f"Saved {output_filename}")
except KeyboardInterrupt:
pass
print('Converting images to pdf')
images = []
for image in images_list:
i = Image.open(image)
images.append(i)
images[0].save(f'{output_dir}/scan.pdf', "PDF", resolution=300.0, save_all=True, append_images=images[1:])
print('Conversion complete') |
Hi, I am trying to do duplex scanning using Python-sane but unable to do duplex scanning please help me ... regards
The text was updated successfully, but these errors were encountered: