Skip to content

Commit 91e336c

Browse files
committed
Version bump
1 parent b86e09f commit 91e336c

5 files changed

Lines changed: 50 additions & 21 deletions

File tree

CHANGES.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Version 2.8.2
2+
-------------
3+
4+
- _sane.c:
5+
6+
- Fix reading of 1bit scan data
7+
8+
- sane.py:
9+
10+
- Fix document feeder out of documents exception checking
11+
12+
113
Version 2.8.1
214
-------------
315

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Python SANE module 2.8.1
1+
Python SANE module 2.8.2
22
========================
33

44
.. image:: https://travis-ci.org/python-pillow/Sane.svg

sane.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# of SANE, consult the documentation at the SANE home page:
66
# http://www.sane-project.org/docs.html
77

8-
__version__ = '2.8.1'
8+
__version__ = '2.8.2'
99
__author__ = ['Andrew Kuchling', 'Ralph Heinkel', 'Sandro Mani']
1010

1111
import _sane

sanedoc.txt

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ sane.init()
4141
Raises _sane.error:
4242
If an error occurs.
4343

44-
sane.get_devices()
44+
sane.get_devices(localOnly=False)
4545

4646
Return a list of 4-tuples containing the available scanning
47-
devices. Each tuple is of the format "(device_name, vendor, model,
47+
devices. If *localOnly* is *True*, only local devices will be
48+
returned. Each tuple is of the format "(device_name, vendor, model,
4849
type)", with:
4950

5051
* *device_name* -- The device name, suitable for passing to
@@ -85,7 +86,8 @@ class class sane.SaneDev(devname)
8586
below, the class has some special attributes which can be read:
8687

8788
* *devname* -- The scanner device name (as passed to
88-
"sane.open()").
89+
90+
"sane.open()").
8991

9092
* *sane_signature* -- The tuple "(devname, brand, name, type)".
9193

@@ -103,7 +105,7 @@ class class sane.SaneDev(devname)
103105
print scanner.mode
104106
scanner.mode = 'Color'
105107

106-
An "Option" object for a scanner option can be retreived via
108+
An "Option" object for a scanner option can be retrieved via
107109
"__getitem__()", i.e.:
108110

109111
option = scanner['mode']
@@ -115,9 +117,8 @@ class class sane.SaneDev(devname)
115117

116118
arr_snap()
117119

118-
Read image data and return a 2d numpy array. For single-band
119-
images, the array shape will be "(width, heigth)", for multi-
120-
band images, the array shape will be "(nbands * width, height)".
120+
Read image data and return a 3d numpy array of the shape
121+
"(nbands, width, heigth)".
121122

122123
Returns:
123124
A "numpy.array" object.
@@ -155,10 +156,13 @@ class class sane.SaneDev(devname)
155156
bytes_per_line)"
156157

157158
* *format* -- One of ""grey"", ""color"", ""red"",
158-
""green"", ""blue"" or ""unknown format"".
159+
160+
""green"", ""blue"" or ""unknown format"".
159161

160162
* *last_frame* -- Whether this is the last frame of a
161-
multi frame image.
163+
multi frame
164+
165+
image.
162166

163167
* *pixels_per_line* -- Width of the scanned image.
164168

@@ -174,6 +178,9 @@ class class sane.SaneDev(devname)
174178
Raises _sane.error:
175179
If an error occurs.
176180

181+
Note: Some backends may return different parameters depending on
182+
whether "SaneDev.start()" was called or not.
183+
177184
multi_scan()
178185

179186
Returns:
@@ -223,18 +230,23 @@ class class sane.Option(args, scanDev)
223230
option.
224231

225232
* *desc* -- A long string describing the option, useful as a
226-
help message.
233+
help
234+
235+
message.
227236

228237
* *type* -- Type of this option: "TYPE_BOOL", "TYPE_INT",
229-
"TYPE_STRING", etc.
238+
239+
"TYPE_STRING", etc.
230240

231241
* *unit* -- Units of this option. "UNIT_NONE", "UNIT_PIXEL",
232242
etc.
233243

234244
* *size* -- Size of the value in bytes.
235245

236246
* *cap* -- Capabilities available: "CAP_EMULATED",
237-
"CAP_SOFT_SELECT", etc.
247+
"CAP_SOFT_SELECT",
248+
249+
etc.
238250

239251
* *constraint* -- Constraint on values. Possible values:
240252

@@ -266,6 +278,8 @@ Example
266278

267279
from __future__ import print_function
268280
import sane
281+
import numpy
282+
from PIL import Image
269283

270284
#
271285
# Change these for 16bit / grayscale scans
@@ -310,7 +324,8 @@ Example
310324
except:
311325
print('Cannot set scan area, using default')
312326

313-
print('Device parameters:', dev.get_parameters())
327+
params = dev.get_parameters()
328+
print('Device parameters:', params)
314329

315330
#
316331
# Start a scan and get and PIL.Image object
@@ -326,16 +341,18 @@ Example
326341
# Initiate the scan and get and numpy array
327342
dev.start()
328343
arr = dev.arr_snap()
329-
print("Array shape: %s, size: %d, type: %s, range: %d-%d, mean: %.1f, stddev: %.1f" %
330-
(repr(arr.shape), arr.size, arr.dtype, arr.min(), arr.max(), arr.mean(), arr.std()))
344+
print("Array shape: %s, size: %d, type: %s, range: %d-%d, mean: %.1f, stddev: "
345+
"%.1f" % (repr(arr.shape), arr.size, arr.dtype, arr.min(), arr.max(),
346+
arr.mean(), arr.std()))
331347

332348
if arr.dtype == numpy.uint16:
333349
arr = (arr / 255).astype(numpy.uint8)
334350

335-
if dev.mode == 'color':
336-
im = Image.frombytes('RGB', params[2], arr.tostring(), 'raw', 'RGB', 0, 1)
351+
if params[0] == 'color':
352+
im = Image.frombytes('RGB', arr.shape[1:], arr.tostring(), 'raw', 'RGB', 0,
353+
1)
337354
else:
338-
im = Image.frombytes('L', params[2], arr.tostring(), 'L', 'RGB', 0, 1)
355+
im = Image.frombytes('L', arr.shape[1:], arr.tostring(), 'raw', 'L', 0, 1)
339356

340357
im.save('test_numpy.png')
341358

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
sources=['_sane.c'])
99

1010
setup(name='python-sane',
11-
version='2.8.1',
11+
version='2.8.2',
1212
description='This is the python-sane package',
1313
py_modules=['sane'],
1414
ext_modules=[sane])

0 commit comments

Comments
 (0)