scanning under windows WIA with custom settings (dpi / etc )

News123 news123 at free.fr
Mon Nov 23 09:30:53 CET 2009


Hi r,

r wrote:
> On Nov 22, 11:32 am, News123 <news... at free.fr> wrote:
>
>> - This script works fine for me under Windows 7, however I'm
>>   unable to   specify additional parameters, like dpi and
>>   color mode.
>
> I have found something interesting but have no idea HOW to implement
> it?? It seems the setting for the scanner are in the registry and must
> be changed that way or by specifically calling these constants on the
> device.
>
> WIA_IPS_YRES (ScannerPictureYres)
> Contains the current vertical resolution, in pixels per inch, for the
> device. An application sets this property to set the vertical
> resolution. The minidriver creates and maintains this property. Type:
> VT_I4, Access: Read/Write or Read Only, Valid Values: WIA_PROP_RANGE
> or WIA_PROP_LIST
>


This sounds interesting.

I do have two questions:

1.) do these entries really have an impact?
---------------------------------------------
Did you find out whether changing the resolution or color mode in the
registry has really an impact when scanning an image with my python script?


2.) Where are these registry entries?
---------------------------------------

Under which windows version did you find these registry entries (XP,
Vista or Win7)?

I can't locate them, but probably my approach is too naive.
I started regedit and searched with CTRL-F for 'WIA_IPS_YRES'.

Perhaps these settings are scanner dependant?


My current script:
# ##################### script start
import win32com.client,os

WIA_IMG_FORMAT_PNG       = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"
WIA_COMMAND_TAKE_PICTURE = "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}"

os.chdir('c:/temp')
wia = win32com.client.Dispatch("WIA.CommonDialog")
dev = wia.ShowSelectDevice()
for command in dev.Commands:
    if command.CommandID==WIA_COMMAND_TAKE_PICTURE:
        foo=dev.ExecuteCommand(WIA_COMMAND_TAKE_PICTURE)
i=1
for item in dev.Items:
    if i==dev.Items.Count:
        image=item.Transfer(WIA_IMG_FORMAT_PNG)
        break
    i=i+1

image.SaveFile("test.png")
######################### script end


bye


N







More information about the Python-list mailing list