Decode QR codes on AppEngine Java - java

I'm trying to decode a QR code which is in a jpeg image, that I post to AppEngine, in the Java version.
I have tried to use ZXing, but couldn't manage to. The obvious solution would be to use their 'Javase' module, but that needs to use BufferedImage and ImageIO, which are not available in AppEngine.
Is there some alternate solution?

You could use the zxing online decoder:
QR code example:
http://thierry-leriche-dessirier.developpez.com/tutoriels/java/creer-qrcode-zxing-java2d-5-min/images/qrcode_dvp.png
php script example:
file_get_contents('http://zxing.org/w/decode?u=thierry-leriche-dessirier.developpez.com/tutoriels/java/creer-qrcode-zxing-java2d-5-min/images/qrcode_dvp.png');
A very good tutorial (in french):
http://thierry-leriche-dessirier.developpez.com/tutoriels/java/creer-qrcode-zxing-java2d-5-min/

Try bundling the BufferedImage and ImageIO jar files into the WEB-INF/lib directory of your project or perhaps the Referenced Libraries of your project in Eclipse.

Related

Reading ND2 files in eclipse

I have created a GUI using java Swing which displays some images. I have been testing it and have managed to create some labels which I have filled with JPEG images as a test.
Now, I face the problem that I cannot display the actual files i need to display because they are .nd2 files (from a Nikon microscope). I have been looking at how to use the Bio-formats and/or IJ packages to do so...but I don't know where to start.
Can anyone help? I am using the Eclipse IDE for Java
About the format
From https://www.file-extensions.org/
... The ND2 format uses JPEG-2000 compression, and also can be
uncompressed or Zip-compressed ...
As mentioned in read jpeg2000 files in java
JPEG 2000 seems to be not included inside standard Java SDK.
Potential solutions
1. Use Open JPEG + existing JNI wrapper
I would try out https://github.com/uclouvain/openjpeg and search for some java wrappers to use openjpeg (e.g. look at https://github.com/barmintor/openjpeg for an JNI approach for maven).
2. Use Open JPEG + Write own JNI wrapper
Another approach would be to look at
https://github.com/ThalesGroup/JP2ForAndroid/blob/master/library/src/main/java/com/gemalto/jp2/JP2Decoder.java , inspect involved classes etc. and write an own JNI wrapper
The mentioned github reposoitory code writes to android bitmap, so not directly usable for your Swing project, but it shows you the way to decode JPEG2000 format by native calls to OpenJPEG library
How to convert a byte[] to a BufferedImage in Java? describes conversion from byte array to a buffered image - so these information should help you to read the image data into a buffered image (so usable in Swing).

executable jar from eclipse unable to use images within packages... sometimes

I have wrote a swing application and it works fine in eclipse but when I export it as a runnable jar parts of the application fail, when dealing with images, this line for example;
logo = getClass().getResource("/com/cogentautomation/logo.jpg").getPath();
eclipse is packaging the images in the com.cogentautomation package and I can see it in the .jar itself, I have tried both export methods, extract required libraries and package required libraries, one says;
FileNotFoundException com\cogentautomation\logo.jpg
the other says;
FileNotFoundException file:\c:\documents\hs.jar!\com\cogentautomation\logo.jpg
I am using a library to parse out a PDF file, which is where this error is occurring, however it works in eclipse and with other images that are on disk that aren't a java resource.
I've read other topics on the problem but nothing really seemed to help.
EDIT: addressing something in the comments, I require a String variable the library I am using requires a string input to read the image;
import org.pdfclown.documents.contents.entities.Image;
Image image = Image.get(logo);
Based on the JavaDocs for org.pdfclown.documents.contents.entities.Image I "guess" the Image.get(String) is forwarding the call to Image.get(File) using the String as the parameter for the constructor of File
This isn't going to work for URL based paths. Instead, you need to look towards Image.get(IInputStream) (why these APIs can't simply use what's already available :P)
So, digging through the API some more IInputStream leads to org.pdfclown.bytes.Buffer, not perfect, but it's a link.
You can use Class#getStreamAsResource and write this into a ByteArrayOutputStream which can then give you a byte[], which can then pass to Image.get(IInputStream)

ImageIo.read method doesn't work in android

ImageIo.read() doesn't work.the error tells that ImageIo class doesn't contains read method.like
ByteArrayInputStream bais=new ByteArrayInputStream(logo);
BufferedImage bimage=ImageIO.read(bais);
any one help me?
ImageIo is part of JRE not directly to android, so you may face problem!!
visit http://docs.oracle.com/javase/7/docs/api/javax/imageio/ImageIO.html
and we can say that Android is not stand art java - it lacks certain classes. what can be suggested is you can go for similar approaches and try to find out some similar straight solution or library project which can help you .
Imaging libraries are not a part of Android development kit. if you want to display images in android you should use BitMap and BitMap Factory classes provided with Android.

Java library to convert InDesign file to image (jpg, png, etc.)

I have a Java webapp that works with InDesign files, I need my application to be able to show a preview of the file and also to send it to the printer. Is there some library that can take the InDesign file and convert it to an image file?
Thanks.
Don't know if you've had any luck with this, but we use imagemagick for this kind of thing. It's not a java library but we access it in java via the command line, and it works really well.

Extracting image pixel values in google appengine

I am working on google appengine to create a tool for comparing image similarity.
I need to extract the pixel values of each image to perform this.
Unfortunately appengine does not support the java image libs.So I am unable to proceed.
Is there any appengine safe image library in java capable of extracting image data?
I saw some techniques in python but dont want to switch to python if I can do it in java somehow...
GAEJ has its own graphic library with fairly limited features and java.awt.image.BufferedImage is a restricted class (ie, java.awt.Image is not supported and still not present in the Jre Class White List ).
There's an open issue here, that you might want to star.
EDIT:
Somebody has patched pngj to work with InputStream.(You could use it to read a PNG pixel by pixel)
The new version of pngj now an alternative pngj-sandbox.jar that only references whitelisted classes, it should run in google-app-engine.
can https://github.com/witwall/appengine-awt help to you? i believe it willbe enough to add theis lib as dependency to the project to make BufferedImage working (but havent' tried this yet)

Categories