4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python3系でJANコードを読みたい件

Last updated at Posted at 2019-06-25

はじめに

 python3系でJANコードを簡単に読みたいと思いました。

環境

 ubuntu 18.04.2 LTS
 python 3.6.7
 zbar 0.10
 pyzbar 0.1.8
 pillow 6.0.0

環境構築

$sudo apt install libzbar0 libzbar-dev
$pip3 install pyber
$pip3 install pillow

対象JANコード

jan_code.png

サンプルコード

decode.py
from PIL import Image
from pyzbar.pyzbar import decode

jan_image = "jan_code.png"

decode_data = decode(Image.open(jan_image))

print(decode_data[0][0].decode('utf-8', 'ignore'))

結果

1234567890128

まとめ

簡単にJANコードがデコードできました。
Mahalo

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?