Tags:
create new tag
, view all tags
PeterThoeny - 2011-02-14:

For the geeks among us: The implementation of the QRCodePlugin was very simple thanks to a CPAN:GD::Barcode::QRcode Perl module that does all the work. It only requires a few lines of code to do the guts:

    use GD::Barcode::QRcode;
    my $image = GD::Barcode::QRcode->new( $text, {ECC => $pEcc, Version => $pVer, ModuleSize => $pSize} )->plot->png;

    my( $dir, $fileName ) = _makeFilename( $theWeb, $theTopic, "$text-$pEcc-$pVer-$pSize" );
    open( PNG, "> $dir/$fileName" ) or return "QRCode Plugin Error: Can't write image file $fileName.";
    binmode( PNG );
    print PNG $image;
    close( PNG );

    my $attachDir = TWiki::Func::getPubUrlPath() . "/$theWeb/$theTopic/$fileName";
    my $html = "<img src='$attachDir' alt='' />";
    return $html;

First we generate the png image using GD::Barcode::QRcode->new() and place it into a $image variable. Then we save the image as a file in the page's attachment directory using a name like _QRCodePlugin_45bfdc4c87f4084e309bb39650020da4.png. To ensure unique image names (in case there are multiple QR Codes in a page), we build a hexadecimal string that is an MD5 hash of the CR Code text, ECC version, symbol version and module size. This is done in the _makeFilename() function:

    use Digest::MD5  qw(md5_hex);
    my $md5 = md5_hex( $string );

Finally we create the html <img ... /> tag and return that to the browser. Interested folks can download the plugin to study the code.

I invite you to get involved with the TWiki community. As a contributor you can influence the direction of the project. Your words become part of the conversation that steers the TWiki project.


PeterThoeny - 2011-02-23:

Special scanners are available to decode a QR Code. There are also web based decoders where you can upload an image or specify the URL of an image, such as:


IshakKang - 2011-03-07:

Thanks for this excellent contribution to the possibilities of developing for QR codes. Its important to follow the ISO standard, yet equally valuable to provide a unique service for encoding. Do you feel that the new corporate structure of Twiki allows start ups to develop solutions collaboratively yet still maintain value to investors?


PeterThoeny - 2011-03-08:

Thanks Ishak. TWiki.org is and remains an open source driven project. We'd love to get you involved to grow our community as a contributor and/or a TWiki consultant. As a company (Twiki Inc) we love to work with ISVs that provide value added solutions, especially now with the new Twiki OnDemand hosting solution.


Topic revision: r4 - 2011-03-08 - PeterThoeny
 

Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.