ZXing in Google App Engine servlet

638 views
Skip to first unread message

József Vesza

unread,
Apr 21, 2014, 6:36:42 AM4/21/14
to zx...@googlegroups.com
I am trying to write a servlet that creates a QR code using zxing. Then I would like to deploy this servlet to GAE. Here is my current implementation: https://gist.github.com/jozsef-vesza/11138874

It works in local development mode, but complans about java.awt.BufferedImage when deployed to GAE. From what I've seen in the zxing sources, there is no way to get around using BufferedImage, but I might be wrong. Is there any way to make this idea work?

Sean Owen

unread,
Apr 21, 2014, 1:48:32 PM4/21/14
to zx...@googlegroups.com
Yes I don't think you can use AWT classes in GAE. I don't know of a way around that other than rewriting a lot of code that parses image files.

This project contains a complete GAE app that does encode QR codes. It used to call to  Google's chart server to make the QR codes, so it didn't do the encoding itself. The chart server is deprecated and will remove QR codes next year.

So I added QR code encoding to the other web app in this project, a servlet-based app, and what is behind zxing.org. So you can make QR codes by requesting URLs like:


(Exactly the same API as the chart server.)

Now, that is what the GAE app uses for encoding. It's still not actually in GAE itself.

József Vesza

unread,
Apr 21, 2014, 4:07:45 PM4/21/14
to zx...@googlegroups.com
Thank you for your answer. It is unfortunate, I was hoping to have the QR generator within my code, but the zxing servlet works well, so it isn't a big issue. :)

Lachezar Dobrev

unread,
Apr 22, 2014, 5:28:42 AM4/22/14
to József Vesza, zxing
You can have the QR code generator, it's in 'core' sub-project, it's
just that you'll need to find another way to generate the image from a
BitMatrix[1] similar to MatrixToImageWriter[2].

I'm not familiar with the GAE ideology, but maybe
ImagesService[3].composite(...) may be used to generate an image from
a resized white pixel (for background) and arranged copies of a black
pixel (for black modules). Probably too tedious, but you have to work
with whatever you have at your disposal.

[1] https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/common/BitMatrix.java
[2] https://github.com/zxing/zxing/blob/master/javase/src/main/java/com/google/zxing/client/j2se/MatrixToImageWriter.java
[3] https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/images/ImagesService
> --
> You received this message because you are subscribed to the Google Groups "zxing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages