Want to Increase Barcode (QR Code specifically) quality and size

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • esforim
    Active Community Member
    • Jan 2020
    • 2204

    Want to Increase Barcode (QR Code specifically) quality and size

    Wanted to know how I can increase the quality and size and possibly error correction for Barcode, QR Code in particular.

    Recently started to play with "VCard" and planning to share it once it is complete, it is a feature I'm adding to the CRM so that I can Scan a single Contact and add it to phone. The issue is that the QR code is too low quality and it can't scan at all on my phone. Even try using the a software reader on Desktop thinking it cause my phone camera suck but even software can't decode it.

    For my test QR total character is: 338 characters total, a sample of it can be found below with a (draft QR Code);

    Code:
    // QR Code to Scan Contact
    barcodeContactQR=string\concatenate(
    "BEGIN:VCARD", '\n',
    "VERSION:2.1", '\n',
    "N:Gump;Forrest;;Mr.", '\n',
    "EMAIL:forrestgump@example.com", '\n',
    "TEL;WORK;VOICE: 111 555-1212", '\n',
    "ADR;WORK;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America", '\n',
    "FN:Forrest Gump", '\n',
    "ORG:Bubba Gump Shrimp Co.", '\n',
    "TITLE:Shrimp Man", '\n',
    "END:VCARD"
    );
    //End QR Code
    Update 2:
    Digging through the code I found this:
    https://github.com/espocrm/espocrm/c...c6b5fbbb58a43f

    "QRcode" => 'QRCODE,H',

    Currently it is already set as "H", reading this website it mean High error correction so I guess there isn't much else we can do for that. ( https://www.qrcode.com/en/about/error_correction.html )

    So I guess the question would be, how to increase the quality/size of the image so it isn't blurry.

    Something about Module and Version on this page: https://www.qrcode.com/en/about/version.html


    Reading more of the code I found this line: for this file: application/Espo/Core/Htmlizer/Htmlizer.php
    $context['hash']['width'] ?? 40,
    $context['hash']['height'] ?? 40,

    I guess I just need to increase that to maybe 100 and 100 and see how it goes? So the next question would be, how to make it update safe? And that is where I think I will be stuck.


    Update 3:
    And the result of my theory? Incorrect, change it to 140, clear cache, re-test it but it size still seem to be the same; hopefully an expert can help
    $context['hash']['width'] ?? 140,
    $context['hash']['height'] ?? 140,
    Last edited by esforim; 09-10-2021, 02:49 AM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    This code concerns PDF printing.

    Code for printing on UI: https://github.com/espocrm/espocrm/b...barcode.js#L89
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • emillod
      Active Community Member
      • Apr 2017
      • 1405

      #3
      Did you thought about using external services such as https://goqr.me/api/ and adding this just as simple image to your pdf? Probably don't want to because of privacy, but you can host your own.

      Comment

      • esforim
        Active Community Member
        • Jan 2020
        • 2204

        #4
        Originally posted by emillod
        Did you thought about using external services such as https://goqr.me/api/ and adding this just as simple image to your pdf? Probably don't want to because of privacy, but you can host your own.
        Not for Contact information that literally a VCard that contain very private information so it must be done internal. And I'm not competent enough to linking two server together unless it is integrated or easily through Shared Hosting server.

        Originally posted by yuri
        This code concerns PDF printing.

        Code for printing on UI: https://github.com/espocrm/espocrm/b...barcode.js#L89
        As for the code, I will give that a try, hopefully it work.

        Please note that I'm using planning to use to use this directly within EspoCRM and not printing it to PDF... so hopefully the code work for both situation.

        ---

        I guess the cherry on top would be how to do it to be upgrade safe, but as long as editing this work that is good enough.
        Last edited by esforim; 09-13-2021, 03:15 AM.

        Comment


        • esforim
          esforim commented
          Editing a comment
          Update: And look good! Working fine, just remember to Clear Cache, Rebuild, Refresh page on your Browser, do an edit so Formula can be rerun and it seem to work.

          You can even change the colors too! But I would not recommend doing so as the camera might have trouble reading it. I initially double the size (256 x 128) but it was not clear enough so VCard Scan, so end up doing (300 x 150) size. It look a bit large in the details view but all it matter it work.

          Will do an update to the formula later in the week and share it.


          ---

          As for Upgrade safe, I went with the lazy man and should work method, I created a Copy, rename it to "barcode.js.backup before edit", make the change to the original files, test to see if it working, copy another copy and rename it to: "barcode.js.backup after edit". Now I can always (hopefully) rely on this two files when upgrade overwrite it.
          Last edited by esforim; 09-13-2021, 03:14 AM.
      Working...