GithubHelp home page GithubHelp logo

Speed up generate barcode about bwip-js HOT 7 CLOSED

metafloor avatar metafloor commented on May 13, 2024
Speed up generate barcode

from bwip-js.

Comments (7)

metafloor avatar metafloor commented on May 13, 2024

Which bar code types are you generating? If a 2D symbol like QR-Code, there is a lot of processing required for the error correction bits. 1D symbols like code128 should render much faster.

from bwip-js.

dannyto avatar dannyto commented on May 13, 2024

I'm using 2D symbol like QR-Code and DataMatrix. So when i generate barcode with value from 1 to 100000, it take a long time. Is there anyway to make it faster for generate?

Thankz!

from bwip-js.

terryburton avatar terryburton commented on May 13, 2024

Is Data Matrix too slow, or just QR Code specifically?

The error correction isn't particularly expensive however QR Code has a very expensive mask evaluation routine to determine which of a set of masks when applied results in a symbol with the least number of undesirable image artefacts. The PS code is about as well optimised as you'll get for this but it's still a performance killer.

One improvement would be allow the user to specify a particular mask and skip the evaluation - not entirely to specification (most other implementations I've seen get the scoring wrong anyway) but it will speed things up and the symbols will still be valid. If this would be helpful then let me know and I'll implement.

from bwip-js.

dannyto avatar dannyto commented on May 13, 2024

Data Matrix is fine, just QR Code. Please help me if you have away to solve it!
Thankz.

from bwip-js.

terryburton avatar terryburton commented on May 13, 2024

@metafloor BWIPP commit 19cb9147aac2ff9519f70ec7f0eeb48060f2be1f introduces an undocumented mask option (1-8 for QR Code, 1-4 for Micro QR Code) that allows the user to pick a particular mask in order to avoid the cost of evaluating each mask for find the optimal. Ignoring the rendering, it reduces the time taken to generate a version 40 symbol from 810ms to 335ms on my system. That's about as good as you can get without micro-optimising a lot of the code for somewhat less gain.

I'm not proud of this as it reduces the quality of the QR Code output so will not cut a release based on this alone, but it's no worse that what a lot of generators do. Some experimentation might be required to determine whether some masks work better than others before settling on one in particular.

It's up to you whether you want to cherry pick it into BWIP-JS or await some future release. I'm choosing not to document the option. You might do likewise!

from bwip-js.

metafloor avatar metafloor commented on May 13, 2024

Attached is the replacement bwipp/qrcode.js file that incorporates the special one-off change (thanks Terry!). Copy it to your bwip-js/bwipp directory. This will not become part of a bwip-js release
until some later date.

Github won't allow uploading .js files so make sure to change the file extension from .txt back to .js.
qrcode.txt

from bwip-js.

dannyto avatar dannyto commented on May 13, 2024

Thank you so much you guy!

from bwip-js.

Related Issues (20)

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.