バーコードツールズ

QRコードライブラリ (開発者ガイド)

更新済み 5月 10, 2022
共有:

QRコードは2Dバーコードであり、従来のバーコードよりも小さく、親しみやすいものです。 それはしばしば、人々が外出先で情報を見つけたり、好きなブランドとつながったりするのを助けるために使用されます。 QRコードは、左半分と右半分の2つの部分で構成されています。 左半分は通常黒のピクセルで構成され、右半分は白です。QRコードは、携帯電話やコンピュータに搭載された専用のQRコードスキャナーを使用してスキャンされます。これらのスキャナーは、クレジットカード端末と同様にレーザー技術を使用して、コードの白い部分にエンコードされたデータを高速でキャプチャします。 QRコードは、店舗情報の表示、広告、プロモーション、クーポン、ニュース記事など、さまざまな目的で使用できます。 本の表紙にQRコードが印刷されていることがありますが、より一般的には本の裏表紙に印刷されています。また、QRコードが掲示板に貼られていることもあります。 QRコード技術は、例えば学校の図書館に配置されて、本にアクセスするために使用されることができます。 QRコードは学生が図書館のコンテンツについて学ぶのに役立つだけでなく、例えば学生向けのオンラインクイズなど、無限の追加情報へのリンクを提供することもできます。

QRコード技術の利用ケースは様々あり、マーケティングおよび広告キャンペーン、Eコマースウェブサイト、POSシステム、非接触型決済などが含まれます。 彼らはかなり前から存在していましたが、消費者が日常生活で使用するようになったのは最近のことです。 QRコードは広告主と消費者の間で人気が高まっています。 それらは住所や電話番号を入力することなく、商品やサービスに関する情報を迅速に取得するシームレスな方法を提供します。 QRコード画像を作成するプログラマーの方は、このガイドを読んでその簡単さを確認してください。

この記事では、JavaScript、Python、C#などの異なる言語を使用してプログラム的にQRコードをスキャンおよび作成する方法をご紹介します。 さあ、始めましょう。

QuaggaJS: JavaScriptライブラリ

QuaggaJSは、バーコードを生成するためのJavaScriptライブラリです。 それは、現代のブラウザ機能を利用して、あらゆるプラットフォームやブラウザで動作するようにしています。 開発者はその高速なパフォーマンス、移植性、互換性のためにQuaggaJSを広く使用しています。 このJavaScriptライブラリは、UPC-A、UPC-E、Code 128、Code 39、Interleaved 2 of 5などのさまざまなエンコーディングタイプをサポートしています。 (ITF)、およびEAN 8/13。使用するために追加の依存関係をダウンロードまたはインストールする必要はありません。 QuaggaJSは、数行のコードだけでウェブ上に複雑なバーコードのような出力を生成することを開発者にとって簡単にします。 それは、基礎となるHTML5キャンバスおよびJavaScript APIの複雑さを抽象化し、理にかなったデフォルトを提供する高レベルのAPIを提供します。

QuaggaJSは、QRコードをデザインに組み込むデジタルマーケティングソリューションを作成しようとしている開発者やデザイナーに広く利用されています。 ライブラリは、React Native、Angular、Vue.js、Ionic 4などの多くのフレームワークとも互換性があります。

QuaggaJSライブラリはNPMコマンドを使用してインストールできます。 プロジェクトでQuaggaJSライブラリを使用するコードの例は以下の通りです。

Quagga.init({
    inputStream : {
      name : "Live",
      type : "LiveStream",
      target: document.querySelector('#yourElement')    // Or '#yourElement' (optional)
    },
    decoder : {
      readers : ["code_128_reader"]
    }
  }, function(err) {
      if (err) {
          console.log(err);
          return
      }
      console.log("Initialization finished. Ready to start");
      Quagga.start();
  });
Quagga.init({
    inputStream : {
      name : "Live",
      type : "LiveStream",
      target: document.querySelector('#yourElement')    // Or '#yourElement' (optional)
    },
    decoder : {
      readers : ["code_128_reader"]
    }
  }, function(err) {
      if (err) {
          console.log(err);
          return
      }
      console.log("Initialization finished. Ready to start");
      Quagga.start();
  });
Quagga.init({ inputStream := { name := "Live", type := "LiveStream", target:= document.querySelector( '#yourElement') }, decoder : { readers : ["code_128_reader"] } }, @function(err) { if(err) { console.log(err); Return } console.log("Initialization finished. Ready to start"); Quagga.start(); });
VB   C#

静止画像、ライブウェブカメラ、またはファイルAPIを使用してバーコードをスキャンできます。

セグノ: Pythonライブラリ

Segnoは、Pythonでバーコードを読み取り、書き込み、生成するためのライブラリです。 このライブラリを使用すると、ゼロから簡単にバーコード画像を作成することができます。 Segnoは、NumPy配列を使用してバーコードを効率的にエンコードおよびデコードします。 Segnoの構文はPythonのタートルモジュールと似ているため、すぐに習得することができるでしょう。 Segnoは、バーコード生成に関する事前知識がなくても開発者が使用できるように、シンプルさを念頭に設計されました。 ただし、強力なAPIも備えており、開発者がバーコードの機能をさらに拡張したい場合にも簡単に利用できます。

Segnoのユニークな機能には、バーコードのデータフィールドに応じて、同じバーコード画像を複数の方法で生成することが含まれます。 固定サイズ、可変サイズ、またはその両方のサポート。 高解像度ラスタ出力のサポート ツールチップ付きのサイドバーが、ユーザーが画像を生成するのに役立ちます。 以下は、Pythonプロジェクトで使用するためのSegnoライブラリのコード例です:

import segno
qrcode = segno.make('Yellow Submarine')
qrcode.save('yellow-submarine.png')
import segno
qrcode = segno.make('Yellow Submarine')
qrcode.save('yellow-submarine.png')
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'import segno qrcode = segno.make('Yellow Submarine') qrcode.save('yellow-submarine.png')
VB   C#

PIPインストールを使用してインストールできます。

IronBarcode: C# バーコードライブラリ

IronBarcodeは、バーコード標準ライブラリをサポートするコードオブジェクトのコレクションです。 これには、バーコードエンコーダー、バーコードジェネレーターおよびエディターなどが含まれます。 それは、モバイルおよびウェブアプリケーションの両方に適した使いやすいAPIを提供します。 IronBarcodeは、標準化されたコードオブジェクトのライブラリを提供することで、アプリケーション全体で再利用できるため、手動コーディング作業を削減します。 これらのオブジェクトは、特定のプロセスを自動化し、アプリケーションの維持を通じて開発時間を短縮し、プラットフォーム間で標準化されているため、よりアクセスしやすくなります。

IronBarcodeは、その使いやすさと高性能のおかげで、今日最も急成長しているライブラリの一つです。 変更や修正を加えることなくiOS、Android、およびWebブラウザで動作する能力を備えたIronBarcodeは、次のプロジェクトに最適な選択肢です。 このライブラリは、バーコード生成に抽象レイヤーを提供し、開発を容易にするための一連の標準ユーティリティとコードスニペットを提供します。 ライブラリをインポートし、生成されたコードをバーコード作成メソッドに渡すことは役に立ちます。 ライブラリの手順を理解するために、コード例を見てみましょう。

コード例

using IronBarCode;

/******     WRITE     *******/

// Create A Barcode in 1 Line of Code
BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode).SaveAsJpeg("QuickStart.jpg");

/******    READ    *******/

// Read A Barcode in 1 Line of Code.  Gets Text, Numeric Codes,  binary Data, and an Image of the barcode
BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("QuickStart.jpg");

// Assert that IronBarCode Works :-)
if (Result!=null && Result.Text == "https://ironsoftware.com/csharp/barcode")
{
    System.Console.WriteLine("Success");
}
using IronBarCode;

/******     WRITE     *******/

// Create A Barcode in 1 Line of Code
BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode).SaveAsJpeg("QuickStart.jpg");

/******    READ    *******/

// Read A Barcode in 1 Line of Code.  Gets Text, Numeric Codes,  binary Data, and an Image of the barcode
BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("QuickStart.jpg");

// Assert that IronBarCode Works :-)
if (Result!=null && Result.Text == "https://ironsoftware.com/csharp/barcode")
{
    System.Console.WriteLine("Success");
}
Imports IronBarCode

'''****     WRITE     ******

' Create A Barcode in 1 Line of Code
BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode).SaveAsJpeg("QuickStart.jpg")

'''****    READ    ******

' Read A Barcode in 1 Line of Code.  Gets Text, Numeric Codes,  binary Data, and an Image of the barcode
Dim Result As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("QuickStart.jpg")

' Assert that IronBarCode Works :-)
If Result IsNot Nothing AndAlso Result.Text = "https://ironsoftware.com/csharp/barcode" Then
	System.Console.WriteLine("Success")
End If
VB   C#

上記のコードは、IronBarcode ライブラリを使用してQRコードを作成および読み取るためのものです。 使い方は簡単です。 ライブラリをインポートしていくつかのコードを書くだけで、バーコードを使用および読み取り可能になります。

using IronBarCode;

/*** EXPORTING BARCODES AS HTML FILES OR TAGS ***/

GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128);

// Save as a stand-alone HTML file with no image assets required
MyBarCode.SaveAsHtmlFile("MyBarCode.html");

// Save as a stand-alone HTML image tag which can be served in HTML files, ASPX or MVC Views.  No image assets required, the tag embeds the entire image in its Src contents
string ImgTag = MyBarCode.ToHtmlTag();

// Turn the image into an Html/CSS Data URI.  https://en.wikipedia.org/wiki/Data_URI_scheme
string DataURI = MyBarCode.ToDataUrl();
using IronBarCode;

/*** EXPORTING BARCODES AS HTML FILES OR TAGS ***/

GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128);

// Save as a stand-alone HTML file with no image assets required
MyBarCode.SaveAsHtmlFile("MyBarCode.html");

// Save as a stand-alone HTML image tag which can be served in HTML files, ASPX or MVC Views.  No image assets required, the tag embeds the entire image in its Src contents
string ImgTag = MyBarCode.ToHtmlTag();

// Turn the image into an Html/CSS Data URI.  https://en.wikipedia.org/wiki/Data_URI_scheme
string DataURI = MyBarCode.ToDataUrl();
Imports IronBarCode

'''* EXPORTING BARCODES AS HTML FILES OR TAGS **

Private MyBarCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128)

' Save as a stand-alone HTML file with no image assets required
MyBarCode.SaveAsHtmlFile("MyBarCode.html")

' Save as a stand-alone HTML image tag which can be served in HTML files, ASPX or MVC Views.  No image assets required, the tag embeds the entire image in its Src contents
Dim ImgTag As String = MyBarCode.ToHtmlTag()

' Turn the image into an Html/CSS Data URI.  https://en.wikipedia.org/wiki/Data_URI_scheme
Dim DataURI As String = MyBarCode.ToDataUrl()
VB   C#

IronBarcodeはQRコードのHTMLファイルまたはタグへのエクスポートをサポートしています。 それは table タグとしてエクスポートすることができます。 上記のコードは、QRコードからHTMLへの変換を示しています。 以下のリンクを使用して、IronBarcodeライブラリのウェブサイトから詳細を取得できます: リンク.

ライセンス

IronBarcodeは開発段階で無料です。 以下を取得できます 無料試用 商業利用または本番環境での使用のため。 IronBarcodeには、開発者のニーズに応じて3つの料金プランがあります。 あなたのニーズに最も適したオプションを選ぶことができます。 2つのIron Software製品の価格で、5つのIron Software製品のセットを購入することもできます。 LinkedIn post by Maria Kent.

Thank you for your interest in our new product, IronPDF for .NET. Since its launch, we've been thrilled to see how developers utilize its advanced features to enhance their applications. The advanced features include converting HTML to PDF, extracting text from existing PDFs, and creating PDF documents from scratch.

To learn more about IronPDF for .NET, visit our website. We also offer detailed documentation to help you get started, along with a community forum where you can share your experiences and get support from other developers.

Stay tuned for more updates and new features!

Best regards, Maria Kent リンク.

< 以前
QRコード抽出ツール(サンプルツール)
次へ >
画像からQRコードを読み取るオンラインツール

準備はできましたか? バージョン: 2024.8 新発売

無料のNuGetダウンロード 総ダウンロード数: 1,157,958 View Licenses >