Skip to content

Commit

Permalink
Merge branch 'release/0.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
heuer committed Oct 17, 2016
2 parents e3a306d + e3c1851 commit 091c102
Show file tree
Hide file tree
Showing 26 changed files with 795 additions and 396 deletions.
17 changes: 16 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
Changes
=======

0.2.2 -- 2016-mm-dd
0.2.3 -- 2016-10-17
-------------------
* Fixed #27: E-mail URI is wrong if CC or BCC is used.
* Fixed #32: Don't add version attribute if SVG >= 2.0
* Deprecated ``writers.get_writable``; use ``writers.writable``
``writers.writable`` closes file-like objects automatically (if necessary);
replace ``writable, must_close = writers.get_writable(filename_or_buffer, mode)``
with ``with writers.writable(filename_or_buffer, mode) as f``
* Added option to PNG serializer to specify an optional DPI value
(thanks to Markus Ueberall for support)
* Added PAM (Portable Arbitrary Map) as serialization format (supports colors
and transparency)


0.2.2 -- 2016-09-21
-------------------
* Command line script reports Segno's version (``--ver``) and the version
is also mentioned in the help message (``-h``) (#24)
* Support for creating E-mail addresses or complete messages (``segno.helpers``)
* Internal optimizations and more correct minimal version finding (#26)



0.2.1 -- 2016-09-15
-------------------
* Fixed Python packaging (source distribution did not work), again
Expand Down
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
Segno -- Python QR Code and Micro QR Code generator
===================================================
Segno -- Python QR Code and Micro QR Code encoder
=================================================

Segno is a QR Code and Micro QR Code generator which has no further
dependencies.
Segno is a QR Code and Micro QR Code encoder which has no further dependencies.

This package implements main parts of ISO/IEC 18004:2006(E) / ISO/IEC 18004:2015(E)
and produces Micro QR Codes and QR Codes with nearly no effort.

Segno provides several serialization formats like SVG, EPS, PNG, PDF, PBM,
LaTeX (PGF/TikZ) or text output. None of these serializers require an external
lib. Segno provides more serialization formats via a plugin architecture. Further,
it provides several high level function to create QR Codes which encode contact
data (MeCard) or WIFI configurations.
lib. Segno could provide more serialization formats via a plugin architecture.
Further, it provides several high level function to create QR Codes which encode
contact data (MeCard) or WIFI configurations.

It requires Python 2.6, 2.7 or Python 3 and works with PyPy.

Expand Down
18 changes: 10 additions & 8 deletions docs/comparison-qrcode-libs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Features
============================================ ================== =================== ================== ========
Description `qrcode`_ `PyQRCode`_ `qrcodegen`_ `Segno`_
============================================ ================== =================== ================== ========
Library license `BSD`_ `BSD`_ `MIT`_ `BSD`_
Library version 5.3 1.2.1 1.0.0 0.2.2
Library license `BSD`_ `BSD`_ `MIT`_ `BSD`_
Library version 5.3 1.2.1 1.0.0 |version|
Mode Numeric Yes Yes Yes Yes
Mode Alphanumeric Yes Yes Yes Yes
Mode Byte Yes Yes Yes Yes
Expand All @@ -19,15 +19,16 @@ Mode Structured Append No No
Mixing modes Yes No Yes Yes
QR Codes version 1 - 40 Yes Yes Yes Yes
Micro QR Codes version M1 - M4 No No No Yes
Output acc. to ISO/IEC 18004:2015(E) Fig. 1 No No No Yes
Output acc. to ISO/IEC 18004:2015(E) Fig. 1 Yes No No Yes
Output acc. to ISO/IEC 18004:2015(E) I.3. No (not available) No (not available) No (not available) Yes
Find best error correction level No No Yes Yes
Find maximal error correction level No No Yes Yes
`PNG`_ output Yes Yes No Yes
`SVG`_ output Yes Yes Yes Yes
`EPS`_ output Yes Yes No Yes
`PDF`_ output Yes No No Yes
`XPM`_ output No Yes No No
`PBM`_ output No No No Yes
`PBM`_ output Yes No No Yes
`PAM`_ output No No No Yes
`LaTeX`_ support No No No Yes
PNG `data URI`_ No kind of (not a URI) No Yes
SVG data URI No No No Yes
Expand All @@ -53,7 +54,7 @@ Default encoding in Byte mode UTF-8 ISO/IEC 88
Performance
-----------

Some performance indicators. The script `benchmark.py`_ ran on a
Some performance indicators. The script `benchmarks.py`_ ran on a
MacBook Air 2,13 Core2 Duo using CPython 2.7.10. Each SVG / PNG image uses a
scaling factor of 10 (aside from qrcodegen which does not support any scaling).

Expand Down Expand Up @@ -98,7 +99,8 @@ Create a QR Code 1-M "QR Code Symbol" and serialize it as PNG image.
.. _EPS: https://en.wikipedia.org/wiki/Encapsulated_PostScript
.. _PDF: https://en.wikipedia.org/wiki/Portable_Document_Format
.. _XPM: https://en.wikipedia.org/wiki/X_PixMap
.. _PBM: https://de.wikipedia.org/wiki/Portable_Bitmap
.. _PBM: https://en.wikipedia.org/wiki/Netpbm_format
.. _PAM: https://en.wikipedia.org/wiki/Netpbm#PAM_graphics_format
.. _LaTeX: https://en.wikipedia.org/wiki/LaTeX
.. _data URI: https://en.wikipedia.org/wiki/Data_URI_scheme
.. _ANSI: https://en.wikipedia.org/wiki/ANSI_escape_code
Expand All @@ -111,4 +113,4 @@ Create a QR Code 1-M "QR Code Symbol" and serialize it as PNG image.
.. _Pillow: https://python-pillow.github.io/
.. _colorama: https://pypi.python.org/pypi/colorama
.. _PIL plugin: https://github.com/heuer/segno-pil
.. _benchmark.py: https://github.com/heuer/segno/sandbox/benchmark.py
.. _benchmarks.py: https://github.com/heuer/segno/blob/master/sandbox/benchmarks.py
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinx_rtd_theme" #'classic' #'alabaster'
html_theme = 'sphinx_rtd_theme' #'classic' #'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Segno - Python QR Code and Micro QR Code generator
==================================================
Segno - Python QR Code and Micro QR Code encoder
================================================

Segno generates QR Codes and Micro QR Codes according to ``ISO/IEC 18004:2015(E)``.
Aside from other Pyhton QR Code generators, Segno has no 3rd party dependencies
Expand Down
5 changes: 2 additions & 3 deletions sandbox/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def svg_qrcode_rects(data='QR Code Symbol'):

def png_qrcode(data='QR Code Symbol'):
"""qrcode PNG"""
qr = QRCode(error_correction=ERROR_CORRECT_M, box_size=10,
image_factory=SvgImage)
qr = QRCode(error_correction=ERROR_CORRECT_M, box_size=10)
qr.add_data(data, optimize=False)
qr.make_image().save('out/qrcode_%s.png' % data)

Expand Down Expand Up @@ -88,7 +87,7 @@ def svg_segno(data='QR Code Symbol'):

def png_segno(data='QR Code Symbol'):
"""Segno PNG"""
segno.make_qr(data, error='m').save('out/segno_%s.png' % data, scale=10)
segno.make_qr(data, error='m').save('out/segno_%s.png' % data, scale=10, addad=False)


def run_create_tests(which=None, number=200, table=None):
Expand Down
6 changes: 3 additions & 3 deletions sandbox/out/chart_create.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions sandbox/out/chart_png.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions sandbox/out/chart_svg.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions sandbox/out/results.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PyQRCode create,37.90
qrcodegen create,24.87
qrcode create,34.97
Segno create,23.31
PyQRCode SVG,49.18
qrcodegen SVG,27.65
qrcode SVG path,99.45
qrcode SVG rects,82.64
Segno SVG,24.98
PyQRCode PNG,113.93
qrcode PNG,82.33
Segno PNG,31.06
PyQRCode create,33.64
qrcodegen create,23.57
qrcode create,32.97
Segno create,23.49
PyQRCode SVG,45.66
qrcodegen SVG,26.71
qrcode SVG path,96.73
qrcode SVG rects,80.07
Segno SVG,25.19
PyQRCode PNG,113.77
qrcode PNG,43.20
Segno PNG,31.81
22 changes: 20 additions & 2 deletions segno/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
VersionError, DataOverflowError
from . import writers, utils

__version__ = '0.2.2'
__version__ = '0.2.3'

__all__ = ('make', 'make_qr', 'make_micro', 'QRCode', 'QRCodeError',
'ErrorLevelError', 'ModeError', 'MaskError', 'VersionError',
Expand Down Expand Up @@ -530,6 +530,11 @@ def save(self, out, kind=None, **kw):
for the ``IDAT`` (data) chunk.
1 is fastest and produces the least compression, 9 is slowest
and produces the most. 0 is no compression.
dpi Default: None. Specifies the DPI value for the image.
By default, the DPI value is unspecified. Please note
that the DPI value is converted into meters (maybe with
rounding errors) since PNG does not support the unit
"dots per inch".
addad Boolean value (default: True) to (dis-)allow a "Software"
comment indicating that the file was created by Segno.
============= ==============================================================
Expand All @@ -543,7 +548,7 @@ def save(self, out, kind=None, **kw):
kind "eps"
scale integer or float
color Default: "#000" (black)
background Default value ``#fff`` (white)
background Default value: ``None`` (no background)
============= ==============================================================
Expand Down Expand Up @@ -597,6 +602,19 @@ def save(self, out, kind=None, **kw):
============= ==============================================================
**Portable Arbitrary Map (PAM)**
============= ==============================================================
Name Description
============= ==============================================================
kind "pam"
scale integer
color Default: "#000" (black).
background Default value ``#fff`` (white). Use ``None`` for a transparent
background.
============= ==============================================================
**LaTeX / PGF/TikZ**
============= ==============================================================
Expand Down
1 change: 1 addition & 0 deletions segno/consts.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# ISO/IEC 18004:2015(E) -- Table 2 — Mode indicators for QR Code (page 23)
MODE_NUMERIC = 0x1
MODE_ALPHANUMERIC = 0x2
MODE_STRUCTURED_APPEND = 0x3
MODE_BYTE = 0x4
MODE_ECI = 0x7
MODE_KANJI = 0x8
Expand Down
17 changes: 0 additions & 17 deletions segno/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,23 +404,6 @@ def add_codewords(matrix, codewords, is_micro):
idx += 1


def make_data_blocks(ec_infos, codewords):
"""\
Divides the `codewords` according to the `ec_infos` into blocks
of codewords and returns a list of blocks.
:param codewords: Iterable of codewords.
:param ec_infos: Iterable of Error Correction information
"""
res = []
offset = 0
for ec_info in ec_infos:
for i in range(ec_info.num_blocks):
res.append(codewords[offset:offset + ec_info.num_data])
offset += ec_info.num_data
return res


def make_final_message(version, error, codewords):
"""\
Constructs the final message (codewords incl. error correction).
Expand Down
2 changes: 1 addition & 1 deletion segno/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def multi(val):
for key, val in (('cc', cc), ('bcc', bcc)):
vals = multi(val)
if vals:
data.append('{0}{1}:{2}'.format(delim, key, ','.join(vals)))
data.append('{0}{1}={2}'.format(delim, key, ','.join(vals)))
delim = '&'
for key, val in (('subject', subject), ('body', body)):
if val is not None:
Expand Down
2 changes: 2 additions & 0 deletions segno/scripts/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def _convert_scale(val):
svg_group.add_argument('--encoding', help='Specifies the encoding of the document',
default='utf-8')
png_group = parser.add_argument_group('PNG', 'PNG specific options')
png_group.add_argument('--dpi', help='Sets the DPI value of the PNG file',
type=int)
png_group.add_argument('--no-ad', help='Omits the "Software" comment in the PNG file',
dest='addad',
action='store_false')
Expand Down
5 changes: 4 additions & 1 deletion segno/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,15 @@ def matrix_iter(matrix, version, scale=1, border=None):
Returns an interator / generator over the provided matrix which includes
the border and the scaling factor.
If either the `scale` or `border` value is invalid, a py:exc:`ValueError`
is raised.
:param matrix: An iterable of bytearrays.
:param int version: A version constant.
:param int scale: The scaling factor (default: ``1``).
:param int border: The border size or ``None`` to specify the
default quiet zone (4 for QR Codes, 2 for Micro QR Codes).
:raises: py:exc:`ValueError` if an illegal border value is provided
:raises: py:exc:`ValueError` if an illegal scale or border value is provided
"""
check_valid_border(border)
scale = int(scale)
Expand Down

0 comments on commit 091c102

Please sign in to comment.