Skip to content

Commit

Permalink
Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Aug 7, 2015
1 parent b86e09f commit 91e336c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 21 deletions.
12 changes: 12 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Version 2.8.2
-------------

- _sane.c:

- Fix reading of 1bit scan data

- sane.py:

- Fix document feeder out of documents exception checking


Version 2.8.1
-------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Python SANE module 2.8.1
Python SANE module 2.8.2
========================

.. image:: https://travis-ci.org/python-pillow/Sane.svg
Expand Down
2 changes: 1 addition & 1 deletion sane.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# of SANE, consult the documentation at the SANE home page:
# http://www.sane-project.org/docs.html

__version__ = '2.8.1'
__version__ = '2.8.2'
__author__ = ['Andrew Kuchling', 'Ralph Heinkel', 'Sandro Mani']

import _sane
Expand Down
53 changes: 35 additions & 18 deletions sanedoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ sane.init()
Raises _sane.error:
If an error occurs.

sane.get_devices()
sane.get_devices(localOnly=False)

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

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

* *devname* -- The scanner device name (as passed to
"sane.open()").

"sane.open()").

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

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

An "Option" object for a scanner option can be retreived via
An "Option" object for a scanner option can be retrieved via
"__getitem__()", i.e.:

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

arr_snap()

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

Returns:
A "numpy.array" object.
Expand Down Expand Up @@ -155,10 +156,13 @@ class class sane.SaneDev(devname)
bytes_per_line)"

* *format* -- One of ""grey"", ""color"", ""red"",
""green"", ""blue"" or ""unknown format"".

""green"", ""blue"" or ""unknown format"".

* *last_frame* -- Whether this is the last frame of a
multi frame image.
multi frame

image.

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

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

Note: Some backends may return different parameters depending on
whether "SaneDev.start()" was called or not.

multi_scan()

Returns:
Expand Down Expand Up @@ -223,18 +230,23 @@ class class sane.Option(args, scanDev)
option.

* *desc* -- A long string describing the option, useful as a
help message.
help

message.

* *type* -- Type of this option: "TYPE_BOOL", "TYPE_INT",
"TYPE_STRING", etc.

"TYPE_STRING", etc.

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

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

* *cap* -- Capabilities available: "CAP_EMULATED",
"CAP_SOFT_SELECT", etc.
"CAP_SOFT_SELECT",

etc.

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

Expand Down Expand Up @@ -266,6 +278,8 @@ Example

from __future__ import print_function
import sane
import numpy
from PIL import Image

#
# Change these for 16bit / grayscale scans
Expand Down Expand Up @@ -310,7 +324,8 @@ Example
except:
print('Cannot set scan area, using default')

print('Device parameters:', dev.get_parameters())
params = dev.get_parameters()
print('Device parameters:', params)

#
# Start a scan and get and PIL.Image object
Expand All @@ -326,16 +341,18 @@ Example
# Initiate the scan and get and numpy array
dev.start()
arr = dev.arr_snap()
print("Array shape: %s, size: %d, type: %s, range: %d-%d, mean: %.1f, stddev: %.1f" %
(repr(arr.shape), arr.size, arr.dtype, arr.min(), arr.max(), arr.mean(), arr.std()))
print("Array shape: %s, size: %d, type: %s, range: %d-%d, mean: %.1f, stddev: "
"%.1f" % (repr(arr.shape), arr.size, arr.dtype, arr.min(), arr.max(),
arr.mean(), arr.std()))

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

if dev.mode == 'color':
im = Image.frombytes('RGB', params[2], arr.tostring(), 'raw', 'RGB', 0, 1)
if params[0] == 'color':
im = Image.frombytes('RGB', arr.shape[1:], arr.tostring(), 'raw', 'RGB', 0,
1)
else:
im = Image.frombytes('L', params[2], arr.tostring(), 'L', 'RGB', 0, 1)
im = Image.frombytes('L', arr.shape[1:], arr.tostring(), 'raw', 'L', 0, 1)

im.save('test_numpy.png')

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sources=['_sane.c'])

setup(name='python-sane',
version='2.8.1',
version='2.8.2',
description='This is the python-sane package',
py_modules=['sane'],
ext_modules=[sane])

0 comments on commit 91e336c

Please sign in to comment.