php_qr-0.1.0.tgz
PHP4/5 ç¨ã® QRã³ã¼ãçææ¡å¼µã¢ã¸ã¥ã¼ã«ã§ãã
ã¤ã³ã¹ãã¼ã«æ¹æ³
é常㮠PHP æ¡å¼µã¢ã¸ã¥ã¼ã«åæ§ã«ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
tar xfz php_qr-0.1.0.tgz cd php_qr-0.1.0 phpize ./configure --enable-qr make sudo make install
PHP ã® GD ã¨ã¯ã¹ãã³ã·ã§ã³ã使ã£ã GIF, JPEG, PNG, WBMP åºåãæå¹ã«ããã«ã¯ --enable-qr-gd ãªãã·ã§ã³ã使ãã¾ãã
zlib ã§å§ç¸®ãã TIFF åºåãæå¹ã«ããã«ã¯ --with-qr-tiff ãªãã·ã§ã³ã使ãã¾ãã
tar xfz php_qr-0.1.0.tgz cd php_qr-0.1.0 if ! -f /path/to/php-install-dir/include/php/ext/gd/libgd/gd.h; then mkdir -p ext/gd/libgd cp /path/to/php-src/ext/gd/libgd/gd.h ext/gd/libgd cp /path/to/php-src/ext/gd/libgd/gdhelpers.h ext/gd/libgd fi /path/to/php-install-dir/bin/phpize ./configure --enable-qr --enable-qr-gd --with-qr-tiff=/path/to/zlib-install-dir --with-php-config=/path/to/php-install-dir/bin/php-config make sudo make install
PHP4/5 å ±éã®æ©è½
以ä¸ã®é¢æ°ãæä¾ããã¾ãã
string qr_get_symbol(string $data[, array $options]); int qr_output_symbol(mixed $output, string $data[, array $options]); string qrcode(string $data[, array $options]);
qr_get_symbol() 㯠$data ã QRã³ã¼ãã·ã³ãã«ã«å¤æãã¦è¿ãã¾ããã·ã³ãã«ã®çæã«å¤±æããã¨ã㯠false ãè¿ãã¾ãã
qr_output_symbol() ã®ç¬¬ä¸å¼æ° $output ã«ã¯åºåå
ã®ãã¡ã¤ã«åãããã¯æ¸ãè¾¼ã¿å¯è½ãªã¹ããªã¼ã ãªã½ã¼ã¹ãæå®ãã¾ãã$output ã空æååã¾ã㯠null ã®å ´åã¯é常ã®åºåãããã¡ã«æ¸ãè¾¼ã¿ã¾ãããã以å¤ã®å ´åã¯ã¨ã©ã¼ã¨ãªãã¾ããè¿ãå¤ã¯ã¹ããªã¼ã ã«æ¸ãè¾¼ã¾ãããã¤ãæ°ã§ã失æããã¨ã㯠false ãè¿ãã¾ãã
qrcode() 㯠qr_get_symbol() ã®ã¨ã¤ãªã¢ã¹ã§ãã
$options ã§ç¬¦å·åããã³åºåã®è©³ç´°ãªè¨å®ããã¾ãã
- version (default: -1)
- çæãã QRã³ã¼ãã·ã³ãã«ã®åçª (1-40)ã-1 ã®å ´åãé常㮠QRã³ã¼ãã§ã¯èªåé¸æãæ§é çé£æ¥ã®å ´å㯠1 ã¨ãªãã
- mode (default: QR_EM_AUTO)
- eclevel (default: QR_ECL_M)
- masktype (default: -1)
- ãã¹ã¯ãã¿ã¼ã³ç¨®å¥ (1-7)ã-1 ãªãèªåé¸æã
- format (default: QR_FMT_DIGIT)
- åºåå½¢å¼ã以ä¸ããé¸æã
- QR_FMT_DIGIT (0,1 ã¨ã¹ãã¼ã¹ã§æ§æãããæåå)
- QR_FMT_ASCII (ã¢ã¹ãã¼ã¢ã¼ã)
- QR_FMT_JSON (JSON)
- QR_FMT_PBM (Portable Bitmap)
- QR_FMT_BMP (Windows Bitmap)
- QR_FMT_SVG (SVG 1.1)
- QR_FMT_TIFF (TIFF, ããã°ã¨ã³ãã£ã¢ã³, deflate å§ç¸®)
- QR_FMT_GIF (GIF)
- QR_FMT_JPEG (JPEG)
- QR_FMT_PNG (PNG)
- QR_FMT_WBMP (Wireless Bitmap)
- TIFF, GIF, JPEG, PNG, WBMP ã®ãµãã¼ããæå¹ã«ããã«ã¯ configure ã§æå®ãå¿ è¦ã
- ã½ããã¦ã§ã¢ã«ãã£ã¦ã¯ deflate å§ç¸®ããã TIFF ã®èªã¿è¾¼ã¿ããµãã¼ããã¦ããªããã®ãããã
- åºåå½¢å¼ã以ä¸ããé¸æã
- magnify (default: 1)
- 1 ã¢ã¸ã¥ã¼ã«ãããã®å¤§ãã (1-16)ã
- separator (default: 4)
- åé¢ãã¿ã¼ã³å¹ (0-16)ãæ¢å®å¤ã® 4 㯠QRã³ã¼ãè¦æ ¼ä¸ã®ä¸éã
- maxnum (default: 1)
- ã·ã³ãã«æ°ã1 ãªãé常㮠QRã³ã¼ãã2 ãã 16 ã®å ´åã¯æ§é çé£æ¥ (é£çµã³ã¼ã) ãçæããããã以å¤ã¯ã¨ã©ã¼ã
- order (default: 0)
- æ§é çé£æ¥ã®å ´åã®ã·ã³ãã«ã®ä¸¦ã¹æ¹ã0 ãªããªãã¹ãæ£æ¹å½¢ã«è¿ããªãããã«ãæ£ã®æ°ãªã横㫠order åãã¤ãè² ã®æ°ãªã縦㫠|order| åãã¤ä¸¦ã¹ããå¤æ¬¡å é åã¨ãã¦åºåãã JSON ã§ã¯ç¡è¦ãããã
PHP5 å°ç¨ã®æ©è½
ãªãã¸ã§ã¯ãæåã® API ãããããã¡ãã§ã¯ç¬¦å·åã¢ã¼ããæ··å¨ãã QRã³ã¼ããä½æãããã§ãã¾ãã
説æã¯ã¾ãå¾æ¥ã
使ç¨ä¾
function qr_output_symbol()
<?php !extension_loaded('qr') && (dl('qr.so') || exit(1)); $data = 'QRã³ã¼ãã¯ãæ ªå¼ä¼ç¤¾ãã³ã½ã¼ã¦ã§ã¼ãã®ç»é²åæ¨ã§ãã'; $data = mb_convert_encoding($data, 'SJIS-win', 'UTF-8'); $options = array( 'mode' => QR_EM_KANJI, 'format' => QR_FMT_BMP, 'magnify' => 2, ); qr_output_symbol('qr.bmp', $data, $options);
class QRCode
<?php !extension_loaded('qr') && (dl('qr.so') || exit(1)); $data = 'QRã³ã¼ãã¯ãæ ªå¼ä¼ç¤¾ãã³ã½ã¼ã¦ã§ã¼ãã®ç»é²åæ¨ã§ãã'; $data = mb_convert_encoding($data, 'SJIS-win', 'UTF-8'); $qr = new QRCode(array('version' => 1, 'maxnum' => 16)); $qr->addData($data, QR_EM_KANJI); $qr->finalize(); $qr->setFormat(QR_FMT_TIFF); $qr->setMagnify(2); $qr->setOrder(-1); $qr->outputSymbol('qr.tiff'); $qr->setFormat(QR_FMT_BMP); foreach ($qr as $pos => $symbol) { file_put_contents(sprintf('qr%d.bmp', $pos + 1), $symbol); }