openpaperwork / pyinsane

Python library to access and use image scanners (Linux/Windows/etc) (Sane/WIA) -- Moved to Gnome's Gitlab
https://gitlab.gnome.org/World/OpenPaperwork/pyinsane
63 stars 24 forks source link

How to change the saving location of scanned document? #43

Closed Maier123 closed 6 years ago

Maier123 commented 6 years ago

Everything is working fine with my pyinsane2 module, I just want to change the saving location of the scanned document, because right now, the document gets stored in the folder your script, that you run to scan, is stored in as well. This comes from line 107 in scan.py: img.save(output_file, "JPEG"). Any tips on what to change for a specific location? And also, but I don't think this is very important, what does "JPEG" stand for in this case(I know this stands for an image ending, but what particular)? I can type in test.pdf and a pdf document will be created.

Maier123 commented 6 years ago

Any ideas anyone?

jflesch commented 6 years ago

This is not a Pyinsane issue.

I don't want to be rude, but at this point the only issue here is that you're obviously not familiar with Python (or any other programming language I would guess ?). I'm sorry but I'm no programming teacher. You would have better luck reading Python tutorials and asking this kind of questions on forums dedicated to learning programming.

Regarding "JPEG", it's a matter of specifying the file format to write (but not the filename nor the file extension (file name ending)) : https://en.wikipedia.org/wiki/Image_file_formats . Here output_file is the variable containing and specifying the file path (and therefore name). And the file could be named toto.png and still be a JPEG image (or toto.jpeg and actually be a PNG image). It's just that Windows systems (and some Linux programs) wouldn't recognize it correctly then.

Maier123 commented 6 years ago

So could I just type "PDF" instead of "JPEG" and it would be a pdf file ? Thats what I actually need, a pdf file...

jflesch commented 6 years ago

Here you are handling a PIL.Image object. They are from the Pillow library, which is an image manipulation library. PDF are not images. Therefore they are not supported by Pillow and img.save(..., "PDF") won't work.

jflesch commented 6 years ago

Oh wait, nevermind. It seems the most recent versions of Pillow do support saving images as PDF files. They will be very basic PDF documents containing only the image, but still, it would actually work.

Maier123 commented 6 years ago

Hey thanks so much for all the help, I was able to finish the project and also solved the question about the saving locations, just now and I would have never been able to do it without your help!! Maybe as a last addition, which is not a major key, but would be cool to add it, would be the device choosing. I tried to use your example code from problem #42 but it didn't work. Do you know how I can find out this number of my device? or was the number just randomly chosen? If so, what do I have to type in instead? When running the normal scan.py script it shows two devices in the console. Using the name shown there doesn't work either...