Looks like Google deprecated their generator in April:

http://googledevelopers.blogspot.com/2012/04/changes-to-deprecation-policies-and-api.html

It still works for now — but won't forever. Are there any plans to integrate an alternative?

Btw — so glad this module exists. Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skyredwang’s picture

Status: Active » Postponed

So we have the time until April 2015? Can we safely postpone the search for replacement?

Anonymous’s picture

I've got the QR Code plug-in in Barcode working with the PHPQRCode library (https://github.com/t0k4rt/phpqrcode). This is my qrcode.inc (Barcode module QR Code plug-in):

function barcode_qrcode_barcode($barnumber, $settings) {
  require_once libraries_get_path('phpqrcode') . '/qrlib.php';

  $name = md5($barnumber);
  $img = $settings->default_path .'/'. $name . $settings->encode .'.png'; 

  header("Content-Type: image/png");
  QRcode::png($barnumber, $img, 'H', 8, 2);
}

You must install the libraries module & install the phpqrcode library in sites/all/libraries.

Notes: I have hardcoded the QR Code size & image format into the plug-in (& also changed the error correction quality to high). phpqrcode library only allows png, svg, & eps formats, I believe. And the size settings are a little more involved with this library than with Google's deprecated service: Google lets you set the image size you want (e.g., 200x200 pixels) & it does all the calculations for module size, etc. See http://www.qrcode.com/en/vertable1.html & http://phpmaster.com/generate-qr-codes-in-php/ for more information about QR Code sizing issues. So the way I have this written, it won't take values from the field's settings for size. I don't have time, unfortunately, to look at the code for those settings & figure out a good way of setting sizes, so I've simply hard-coded it for my needs.

If anyone wants to take this & incorporate it into Barcode, feel welcome to do so.

H.

Anonymous’s picture

Status: Postponed » Needs review

Google's going to be shutting down its QR Code generator, on which this module depends. I have got it working using the phpqrcode library instead.

You can use the code above to integrate with the library. One issue I had is that you couldn't define an absolute size in pixels for your bar code. I found a patch to the QR Code library that will allow you to do that. At:

http://sourceforge.net/tracker/?func=detail&aid=3543454&group_id=311533&...

Apply the patch to your phpqrcode library, then use the following code in the barcode module's qr code plugin:

function barcode_qrcode_barcode($barnumber, $settings) {
  require_once libraries_get_path('phpqrcode') . '/qrlib.php';

  $name = md5($barnumber);
  $img = $settings->default_path .'/'. $name . $settings->encode .'.png'; 

  header("Content-Type: image/png");
define('IMAGE_WIDTH',200);
define('IMAGE_HEIGHT',200);
  QRcode::png($barnumber, $img, 'H', 10, 0);
}

Works perfectly for me. Hope the developers will be able to use this info.

stewart.adam’s picture

Attached patch based on #2 works for me. I removed the header call, as I want the QR code generation to work like other the plugins where it generates the image and the theme() call returns the image instead of displaying it directly in the browser.

SocialNicheGuru’s picture

so do I need to apply the patch in #4 and make the change in $3

stewart.adam’s picture

They are equivalent, so you can use whichever of the two you are more comfortable with.

If you choose to avoid the patch and use #3, keep in mind my comments above though - it will always display the image immediately instead of returning an image file for display later.

cdeces’s picture

Google QR Code generators has stopped working. I've implemented solution #4 and tweaked the image size in the code.
But, this solution would need a better integration with the module, for instance to pass the image format, and image size from the field configuration to the phpqrcode library.

Anonymous’s picture

Version: 7.x-2.1 » 7.x-2.x-dev
Category: Feature request » Bug report
Priority: Normal » Critical
Status: Needs review » Needs work

This is now critical as the current QRCode functionality is broken by the demise of Google's QRCoding service. Also a bug for the same reason.

The phpqrcode library will not natively let you set an absolute size in pixels for height & width. For different inputs you will get different sizes of QRCodes. In order to be able to set an absolute size for your barcodes using the phpqrcode library you must apply the patch at Sourceforge I linked to in #3 to your phpqrcode library (not to this module). Then what I did was hardcode my chosen dimensions into the QRCode plugin of the barcode module

The patch at #4 does not account for the lack of settings for fixed dimensions in the stock phpqrcode library, so keep that in mind if that's important to you.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
510.85 KB

I am attaching a patch that makes the Barcode module use the phpqrcode library to generate QRCodes.

What it does:

1) Changes the settings form to permit selecting PNG or SVG format for QRCodes, & also the qrcode.inc plugin will now use the height setting here for its image dimensions.

2) Changes qrcode.inc to use the phpqrcode library. It will use the settings from the field settings page (see above). It includes definitions to permit the size in pixels setting to work with the phpqrcode library. Contrary to my previous code, it doesn't set a header, so it incorporates the changes suggested in #4.

3) It includes the phpqrcode library as a subfolder of the Barcode module. The version incorporated here has been patched with the patch I mentioned at #3, which permits the phpqrcode library to output images of a fixed pixel width & height. That is the only reason I am including it in this patch rather than suggesting installing it as a library with the Libraries module. It also accounts for the patch's size; apart from the phpqrcode inclusion it is quite small.

It applies cleanly against the most recent dev & works for me with both png & svg images, saving them to the public files directory as normal with the dimensions specified in settings.

Please review & commit soon, as this is completely broken currently.

Anonymous’s picture

Whoops. The last patch I uploaded had some extraneous files. This one is clean & is the one to be reviewd.

BBC’s picture

Patch #10 seems to be working nicely. I tried both png and svg modes. Only hiccup was that I had to adjust ownership on the phpqrcode/cache directory to the www-data user in order to avoid a series of PHP warnings.

Thanks much!

skyredwang’s picture

Status: Needs review » Needs work

@rhclayto Can you link to your phpqrcode library? We need to review the license and other things.

In general, we need to find an open source library to replace the existing library that we have been using (I don't think anyone has ever updated it since 2009 when I got it in first time). Ideally, we want to use one library that can generate QRCode as well as other types of barcode.

This one seems to be a good candidate https://github.com/dineshrabara/barcode , but I haven't tested it yet

Anonymous’s picture

Hi,

Actually the whole patched library is part of the patch at #10, so you can see the whole thing in the patch. The license of the library is GPLv3.

skyredwang’s picture

@rhclayto, I want to evaluate the library you included, like documentation, and community, etc.

On the other hand, we should use either Libraries API or Composer Manager to manage external library. (The reason that I didn't use it before, it is because it was in 2009.)

skyredwang’s picture

dineshrabara/barcode project is based on Laravel. I don't think we want to bring in another framework just for generating barcodes.

But, as the author of TCPDF pointed out here, https://github.com/tecnickcom/tc-lib-barcode might be most complete.

edxxu’s picture

Can we use http://phpqrcode.sourceforge.net/ to generate QR code?

stewart.adam’s picture

@eduxxu that library hasn't seen updates in ages and if I remember correctly, setting image size dynamically is difficult and requires a patch + declaration of PHP constants.

HongPong’s picture

It looks like tc-lib-barcode is still being actively developed and just had a tagged release 6 days ago so that is very promising I think.