Zxing web decodes Aztec code with base64 padding but 3.4.0 jars produce no barcode found - zxing

Running the latest java version produces "no barcode found" on an image.
java -cp core-3.4.0.jar:javase-3.4.0.jar:jcommander-1.72.jar:jai-imageio-core-1.4.0.jar com.google.zxing.client.j2se.CommandLineRunner --try_harder ./IMG.jpg
file:///home/tom/Projects/mTicketing/zxing_java/./IMG.jpg: No barcode found
However, using the web site https://zxing.org/w/decode and the same image produces:
eyJ2ZXJzaW9uIjoidGZpLjEiLCJhbGciOiJSUzI1NiIsImFjdCI6IjIwMjAtMDQtMjhUMDc6NTc6NDYrMDE6MDAifQ==.eyJkdXIiOiJQVDkwTSIsIm9wIjoiQnVzIEVpcmVhbm4iLCJwciI6IlNpbmdsZSBKb3VybmV5IFRpY2tldCBBZHVsdCIsImZyb20iOiJDbGFyZWNhc3RsZSIsInRvIjoiU2hhbm5vbiBJbmR1c3RyaWFsIEVzdC4iLCJybiI6IjExMjE5IiwiYW4iOiJUb20gQnlybmUiLCJ1dG4iOiI2OTE2NDQzOC02M2RkLTRhY2YtOGZlNS01MjUyMjZmYjhmOTcifQ.Aw_3tELIvR6EqatwR-QxwXC5V1F7Cznr0FfZkl8O8SIYzwcOyJ_coCqBs_2UKMghv0WVNAXikHmavMqLLEaug2H41ElFs48lBz8yEgsCsrbeau2AWDd14KixsfITx3rps9HqMf-aPxb5B3Dw6vYFh2Gnokb1Dhbqfhb1a5j5UJI
However, if the base64 padding is removed from the header in the JWT token ('==') and a QR code generated, the barcode is decoded successfully by both the site and the java code.
I know Base64Url should be used but why is the image successfully decoded by the zxing site and not by the latest jar files?
And why would padding produce an image that is hard to decode?

So, after some more research, I'm pretty sure that the issue I noticed was associated with the length of the data encoded and the resolution of the device displaying the Aztec code and nothing to do with the padding.
As the length of encoded data increases in size, the visual complexity of the Aztec QR code increases. I found that if I used a lower resolution device or deliberately set the screen resolution of a device to low, more complex codes were not reliably decoded.
There was some differences between the ZXING site and the java code but I suspect the site may have a set of decode hints pre-configured.

Related

Paid charts are not shown in the PDF

we have a doubt regarding your platform. We use it to generate graphics in the pdf of our platform. Everything was perfect with the free graphics, however with the payments (white mark), we observed that these are not shown in the pdf.
As said earlier through our support, the URL encoding might be the issue and triggers an invalid HMAC signature error :)

ZXing-cpp can't decode image

I'm interest in extracting barcode image. And I'm using ZXing C++ Port from https://github.com/glassechidna/zxing-cpp.
But when I build with cmake and run with all barcodes which ZXing support, only 8/15 barcodes can be decoded, including:
Code 39, Code 93, Code 128, ITF, Codabar, Aztec, UPC-A and UPC-E
The remaining barcodes: QR Code, Data Matrix, PDF 417, EAN-8, EAN-13, RSS-14 and RSS Expanded can't be decoded.
And I don't know why, while with the same barcodes, I test in ZXing home page (online) from: http://zxing.org/w/decode.jspx, all barcodes are decoded normally.
Anyone has been met as same as me? Or if you know why, please help me!
Anyone looking for an up-to-date c++ port of ZXing, you might want to give https://github.com/nu-book/zxing-cpp a try. It can decode all the mentioned codes and do that more reliably and faster than the original Java upstream project.

How to display the images in offline using ionic

I have a gallery module, the functionality implemented in this module as below
- getting the file path from the server using ajaxrequest
- the response will be json object of all image file path
- setting the filepath in image src attribute
As we are using ajax request, the images are loading in online mode only.
so how to implement the functionality so that images should show in offline also.
You may consider returning images as base64 string from the server and store them in a localstorage.
On the view use data-ng-src directive like this .
In your controller check if there is no connection and set base64 string from the localstorage as this: $scope.data.image_url=
After loading an image once, your best bet is going to be get a base64 representation of it, and then persisting that to disk.
Get the base64 representation of the image here:
Get image data in JavaScript?
Write the base64 data to disk using ng-cordova/ionic native and the writeFile method using the Cordova file plugin.
http://ngcordova.com/docs/plugins/file/
writeFile(path, file, data, replace)
There are some great answers here that I would like to build on...
I would suggest using PouchDB as a cache for base64 and/or Blob data after you have downloaded the original (one of my apps does the same thing with mp3 data converted to a Blob). You could then implement a method that checks the cache for the image before making a network request.
Nolan Lawson has created an excellent library for these binary conversions: https://github.com/nolanlawson/blob-util
Just save the base64 string to your PouchDB instance after the initial download, you can then check for that data before your app reaches out to the network.
Just beware of storage limits on iOS Safari (~50mb default)...

iText form filling missing PDF content

I am running into an odd problem with iText. I have a document with a few fields. On my server, I open the local document, set the fields and send the output of the stamper to the browser.
Works perfectly on my local devel machine.
The pdf generated on the server is missing the PDF contents. I only see the content of the fields I set, the rest is completely blank.
Any tips?
Your application on your local machine respects the bytes of the PDF you're using as a template. Your application on the server doesn't respect those bytes. Maybe you've copied the template using the wrong encoding, making all the binary characters corrupt. Or maybe your application is reading the template using the wrong encoding with the same result.
You can find out by opening your PDF file in a text editor (not inside a PDF viewer). Look for the keyword stream and inspect the bytes that follow this keyword. Do you see the difference? In the PDF produced on your local machine, the bytes look like a normal binary stream. In the PDF produced on your server, the bytes look awkward. For instance: it consists of plenty of question marks.
How to solve: check if the template was copied correctly. If so, check the way you're reading the document. For instance: read the PDF template into a byte array without using iText and write it to a new byte array. Can you reproduce the process of corruption? If so, tweak your application (the one that doesn't involve iText) until you've got the correct encoding.

OCR reconizes stranges characters. Why?

I'm using OCR to develop an Android Application using the Tesseract Libs, with the tess-two project, as I saw here: http://gaut.am/making-an-ocr-android-app-using-tesseract/
The app worked fine, but I'm repairing that string returned with the content of a photo, sometimes, comes with strangers characters. Example: I'm reading this: www.caelum.com.br and receiving something like this: r ' . ,wlñzf . 94' kzl 5. vsmNs/.caelumcombr
Searching, I've configured this: baseApi.setVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
But I think that becomes worst.
I want to read texts in Portuguese and English. So, I downloaded the traineddata for each language and using it as I wish, but these strangers characters have something to do with the encoding project ?
Thanks for help :)
Tesseract recognizes text only for images that contains text and only text. Images that contains only text will be accurately recognized by it and you can get good accuracy too.
However Tesseract gives garbled output for image + text recognition.
I didn't worked on this recognition so can't help further.
So your question should be as to how to crop the image part so that you get only the text part out from image. Like that Tesseract can recognize fine and give desired text in ouput.
Thanks.