import twain
sm = twain.SourceManager(0)
ss = sm.OpenSource()
ss.RequestAcquire(0,0)
rv = ss.XferImageNatively()
if rv:
(handle, count) = rv
result = twain.DIBToBMFile(handle)
and got error:
Traceback (most recent call last):
File "Y:\My_scripts\scan\scanner.py", line 27, in <module>
result = twain.DIBToBMFile(handle)
File "Y:\My_scripts\scan\twain.py", line 2302, in DIBToBMFile
return _dib_write(handle, path, _GlobalLock, _GlobalUnlock)
File "Y:\My_scripts\scan\twain.py", line 2247, in _dib_write
_write_bmp(f)
File "Y:\My_scripts\scan\twain.py", line 2232, in _write_bmp
f.write(b'BM')
TypeError: string argument expected, got 'bytes'
For fix this, you need change f = io.StringIO() to f = io.BytesIO() in twain._dib_write function.
I am trying this code out below.
and got error:
For fix this, you need change f = io.StringIO() to f = io.BytesIO() in twain._dib_write function.