Giter Club home page Giter Club logo

segno's People

Contributors

alexbeattie42 avatar barbashovtd avatar bitcoinhodler avatar christian-oudard avatar derbiasto avatar eduardomazolini avatar heuer avatar jayaddison avatar missionfloyd avatar neycyanshi avatar stefanoborini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

segno's Issues

find_version should operate with bits and not with modes

encoder.find_version takes the character count (len(data)) and the individual modes into account. This may lead to suboptimal versions. find_version should take the number of bits into account. Further, it should take the overhead (mode indicator, length of char indicator) into account, see TODO.

Provide helpers.make_XXX in segno.__init__?

The helpers module provides several factory functions to create QR Codes for e-mail addresses, contacts, ...

Might be nice if at least the make_XXX (and not make_XXX_data) functions would be available with a simple import segno import:

Currently:

>>> from segno import helpers
>>> qr = helpers.make_email('[email protected]')

If segno.__init__ imports the factory functions:

>>> import segno
>>> qr = segno.make_email('[email protected]')

The factory functions of helpers differ from the usual factory functions, though. They don't allow to set the minimum error level / version ...

Inkscape plugin?

Would be nice if Segno could be used as Inkscape extension.
Maybe a subproject?

boost_error=True creates invalid QR Codes

>>> import segno
>>> qr = segno.make('http://www.example.org/bla/bla/')
>>> qr.show()  # Does not scan
>>> qr.designator
'3-H'
>>> qr = segno.make('http://www.example.org/bla/bla/', boost_error=False)
>>> qr.show()  # Works!
>>> qr.designator
'3-M'
>>> # Setting the error level to 'H' works, too
>>> qr = segno.make('http://www.example.org/bla/bla/', error='h')
>>> qr.show()  # Works!
>>> qr.designator
'4-H'
>>> # boost_error should choose error level "Q" which does not change the QR Code version
>>> qr = segno.make('http://www.example.org/bla/bla/', boost_error=False, error='q')
>>> qr.show()  # Works!
>>> qr.designator
'3-Q'

print stmt in test_pbm.py

test_pbm.py / line 54 ...

        if l.startswith(b'P') or l.startswith(b'#'):
            print('Skip line', l)
            continue

from segno import * fails

>>> from segno import *

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    from segno import *
TypeError: Item in ``from list'' must be str, not unicode

Console script (Windows): Error for struct.unpack

Error:

default_color = struct.unpack("hhhhHhhhhhh", csbi.raw)[4]
TypeError: Struct() argument 1 must be string, not unicode

Solution:
writers.py / line 770

    default_color = struct.unpack(b'hhhhHhhhhhh', csbi.raw)[4]

Choose error level more lenient

If the user specifies the version but not the error level, a DataOverflowException may be raised

>>> import segno
>>> qr = segno.make('Wikipedia', version='M3')
Traceback (most recent call last):
[...]
DataOverflowError: The provided data does not fit into version "M3". Proposal: version M4

If Segno would not insist on error level M (default), the symbol can be generated:

>>> import segno
>>> qr = segno.make('Wikipedia', version='M3', error='l')
>>> qr.designator
'M3-L'

segno always append '0a' to the content

I use onlinebarcodereader to decode the qrcode that generate by segno and I find it always auto append '0a' to the content in hex values. How to remove it?

CLI should not raise exceptions but return an error code

Would be nice if CLI would not show the traceback but simply return an error code and show the message from the exception

$ segno --micro This does not fit into a micro code
Traceback (most recent call last):
[...]
segno.encoder.DataOverflowError: Data too large. No Micro QR Code can handle the provided data

Accept percentual values for error correction level?

Segno could accept something like

>>> import segno
>>> segno.make('Avalanche', error=.07)
>>> segno.make('Tupelo', error=.25)

where the error value refers to the corresponding error levels "L", "M", "Q", "H".

PyQRCode, for example, accepts values like "7%" etc.

I don't think that PyQRCode's behaviour adds any value, maybe

>>> segno.make('Mermaids', error=7) 
>>> segno.make('Deanna', error=25) 

would make more sense.

If it makes sense at all...

Thanks!

This library is very well done:

  • Has all features I could want.
  • Nice API.
  • Helpful CLI tool.
  • Great docs & changelogs.
  • No dependencies.
  • Fast.
  • Has tests.
  • Permissive license.
  • Can even render to the terminal!

It should be the default choice for QR handling in Python. Just wanted to say thanks for the hard work :)

Accept unquoted space delimited content as last item of cmd line

Does not work:

segno --scale 10 --output good-times.png Good Times
usage: segno [-h] [--version VERSION] [--error {L,M,Q,H,-}]
             [--mode {numeric,alphanumeric,byte,kanji}] [--pattern PATTERN]
             [--scale SCALE] [--border BORDER] [--micro] [--no-micro]
             [--color COLOR] [--background BACKGROUND] [--output OUTPUT]
             [--no-error-boost] [--no-classes] [--no-xmldecl] [--no-namespace]
             [--no-newline] [--title TITLE] [--desc DESC] [--svgid SVGID]
             [--svgclass SVGCLASS] [--lineclass LINECLASS] [--no-size]
             [--unit UNIT] [--svgversion SVGVERSION] [--encoding ENCODING]
             [--dpi DPI] [--no-ad] [--ver]
             content
segno: error: unrecognized arguments: Times

Works:

segno --scale 10 --output good-times.png "Good Times"

Problem with micro QR code generation

Hi,

I was trying to generate some micro QR codes that should be read by someone else, but they reported that they could not read them.
After some investigation, it seems that the code for generating format information for micro QR codes is wrong, except for M1 and M2-L code.

The patch below seems to fix that problem, although the people who read my codes still report they can’t read the M3 codes I generated (M2 and M4 seemed to be fine)…

Cheers,

--
Nicolas Boullis

diff --git a/segno/encoder.py b/segno/encoder.py
--- a/segno/encoder.py
+++ b/segno/encoder.py
@@ -786,12 +786,15 @@ def add_format_info(matrix, version, err
     is_micro = version < 1
     offset = int(is_micro)
     fmt = mask_pattern
-    if error == consts.ERROR_LEVEL_L:
-        fmt += (0x08 if not is_micro else 0x4)
-    elif error == consts.ERROR_LEVEL_H:
-        fmt += (0x10 if not is_micro else 0xe)
-    elif error == consts.ERROR_LEVEL_Q:
-        fmt += (0x18 if not is_micro else 0x14)
+    if is_micro:
+        fmt += consts.ERROR_LEVEL_TO_MICRO_MAPPING[version][error] << 2
+    else:
+        if error == consts.ERROR_LEVEL_L:
+            fmt += 0x08
+        elif error == consts.ERROR_LEVEL_H:
+            fmt += 0x10
+        elif error == consts.ERROR_LEVEL_Q:
+            fmt += 0x18
     format_info = consts.FORMAT_INFO[fmt] if not is_micro else consts.FORMAT_INFO_MICRO[fmt]
     for i in range(8):
         bit = (format_info >> i) & 0x01

Structured Append

This allows files of data to be represented logically and continuously in up to 16 QR Code symbols. These may be scanned in any sequence to enable the original data to be correctly reconstructed. (c.f. chapter 8)

Minor priority since the usual QR Code readers do not support this mode; might be a "nice to have"

Remove PDF support?

Segno supports EPS and SVG. Is the PDF output useful at all? Maybe it should become a plugin.

Command line: Support plugins

Would be nice if plugins and their specific keywords could be supported:

$ segno 'Cocaine' --plugin=glow deviation=.4 filter-id=boah -o=cocaine.svg

vcard field

Thank's for your work.

Is it possible to know all the different vcard fields we can introduce with segno? on segno.readthedocs.io, I only see the following parameters :
qr = helpers.make_vcard(name='Doe;John', displayname='John Doe', email='[email protected]', phone='+1234567')

but there are many others parameters :
https://en.wikipedia.org/wiki/VCard#Properties

Make helpers factory functions available in command line script?

The factory functions of helpers.py aren't accessible through the command line script; might be useful to find a way to expose them.

segno wifi network=x password=y

Probably it might be more useful to utilize the make_XXX_data factories since the command line script could set the error level and QR Code version

Error level: Minimum level vs. explicit level

Would be nice if a minimum error level could be provided. If the data is small enough, the algorithm could increase the error level automatically (version must be the same).

>>> import segno
>>> qr_m = segno.make_qr('ABCDE', error='m')
>>> qr_m.designator
'1-M'
>>> qr_h = segno.make_qr('ABCDE', error='h')
>>> q_h.designator
'1-H'
>>> qr_h.symbol_size()  == qr_m_symbol_size()
True

The above should be done automatically, if the user wants it

>>> import segno
>>> qr = segno.make_qr('ABCDEF', please_increase_error_level_if_possible=True)
>>> qr.designator
'1-H'
>>> # With an explicit error level
>>> qr = segno.make_qr('ABCDEF', error='l', please_increase_error_level_if_possible=True)
>>> qr.designator
'1-H'

Add contact 'photo' field to vcards

I would be nice to add the photo field to the vcard

https://tools.ietf.org/html/rfc6350#section-6.2.4

Examples:

   PHOTO:http://www.example.com/pub/photos/jqpublic.gif

   PHOTO:data:image/jpeg;base64,MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhv
    AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm
    ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0
    <...remainder of base64-encoded data...>

Validity check for user provided mask index is wrong

    if is_micro:
        if not 0 <= mask <= 4:
            raise MaskError('Invalid data mask "{0}" for Micro QR Code'.format(mask))
    else:
        if not 0 <= mask <= 8:
            raise MaskError('Invalid data mask "{0}"'.format(mask))

Correct: 0 <= mask < 4 and 0 <= mask < 8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.