QR code in JPEG or TIFF using Python without PIL or PILLOW

I'm running python (v3.4) in IBM I / AS400 (very similar to mainframes) to generate QR code dynamically to print in customer statements.
Using PyQRCode and PyPNG, I've generated QR code in PNG file. But PNG isn't supported in IBM I, neither is SVG or EPS.
Hence I need to convert PNG to JPEG or TIFF. BUT again PILLOW/numpy is not an option as there was no C/CPP in AS400 and GCC couldn't be setup properly.
So, need to convert (or generate) QR Code in JPG using only pure python libraries.

I'm very new to python and not getting clear leads on ways to
i) generate QR code in JPEG
  or
ii) to convert PNG/SVG to JPG without PIL/PILLOW

any help?
Rajesh MohanaSundaramAsked:
Who is Participating?
 
Martin MillerConnect With a Mentor CTOCommented:
Can you use this on the AS400 ? PyQRCode 1.2.1, A QR code generator written purely in Python with SVG, EPS, PNG and terminal output.
0
 
Rajesh MohanaSundaramAuthor Commented:
Yes, generated QR code using PyQRCode 1.2.1 in AS400 but not able to embed PNG file in to PDF.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Martin MillerConnect With a Mentor CTOCommented:
Got it, I haven't tried doing this, but found this link:

https://www.tylerlesmann.com/read/writing-pdfs-python-adding-images
0
 
gelonidaCommented:
I don't know what tools are installed on the AS400.

If you have any command line tool (like for example imagemagick), that can convert png to jpg, then you could call that external tool from Python with subprocess.Popen() / subprocess.call()
0
 
aikimarkCommented:
There are several web sites that will generate a QR code, based on text that you post.
0
 
gelonidaConnect With a Mentor Commented:
aikimark's suggestion is a good one if your data is not confidental.
It will probably be the easiest one to implement if you find a web site that allows automation. a good library to perform http accesses to web sites could be requests.
You could install it with
pip install requests

Open in new window

0
 
Rajesh MohanaSundaramAuthor Commented:
our system generates more than 3000 statements in less than 5 minutes.  generating QR code via another website is not a reliable solution. On top of it, it's confidential data. There is a software for generating encrypted QR code but that runs outside AS400. We are trying to avoid unnecessary dependency as Python can generate it within the system. But conversion from SVG/PNG to JPG/TIFF is the stumbling block.
0
 
aikimarkCommented:
Why convert the image?
0
 
aikimarkConnect With a Mentor Commented:
have you tried the openCV library
import CV2

Open in new window

0
 
Rajesh MohanaSundaramAuthor Commented:
Existing PDF generation process in IBM I doesn't support SVG or PNG. Only JPG to TIFF is accepted.
0
 
aikimarkConnect With a Mentor Commented:
Something to try:
1. Generate a lot of png/svg files in a directory.
2. Execute a Python script, using Pillow, on a non-IBM system to convert the files to jpg/tiff and place them into a different directory.
3. Time the performance of step 2

If you can convert more than 10 image files per second, then you have at least one work-around solution.  It may not be an ideal solution, but it will give you a functional solution.

You should create around 27000 png/svg files for your test.
1
 
aikimarkCommented:
@Rajesh

Where do you stand with this problem?  Do you have work-around or solution?
0
 
Martin MillerCTOCommented:
Can we close this question ?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.