Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have tried running libjpeg-turbo on color images that have an alpha channel and which have been saved with java's ImageIO as jpeg.</p> <p>This is how I compiled libjpeg-turbo for linux 64-bit:</p> <pre><code>$ autoreconf -fiv $ mkdir build $ cd build $ sh ../configure --with-java CPPFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux" $ make $ cd .. $ mkdir my-install $ cd build $ make install prefix=$PWD/../my-install libdir=$PWD/../my-install/lib64 </code></pre> <p>This is how I run Fiji with the correct library path and classpath, to include libjpeg-turbo:</p> <pre><code>$ cd Programming/fiji $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/../java/libjpeg-turbo/libjpeg-turbo/my-install/lib64 $ ./fiji -cp $PWD/../java/libjpeg-turbo/libjpeg-turbo/my-install/classes/turbojpeg.jar </code></pre> <p>This is a small jython script to read such jpeg+alpha files:</p> <pre> ###### path = "/home/albert/Desktop/t2/trakem2.1263462814399.1347985440.1111111/trakem2.mipmaps/0/17.07may04b_GridID02043_Insertion001_00013gr_00005sq_00014ex.tif.jpg" from org.libjpegturbo.turbojpeg import TJDecompressor, TJ from java.io import File, FileInputStream from java.awt.image import BufferedImage from jarray import zeros f = File(path) fis = FileInputStream(f) b = zeros(fis.available(), 'b') print len(b) fis.read(b) fis.close() d = TJDecompressor(b) print d.getWidth(), d.getHeight() bi = d.decompress(d.getWidth(), d.getHeight(), BufferedImage.TYPE_INT_ARGB, 0) ImagePlus("that", ColorProcessor(bi)).show() #### </pre> <p>The problem: no matter what flag I use (the '0' above in the call to decompress) from the TJ class (see <a href="http://libjpeg-turbo.svn.sourceforge.net/viewvc/libjpeg-turbo/trunk/java/doc/org/libjpegturbo/turbojpeg/TJ.html" rel="nofollow">http://libjpeg-turbo.svn.sourceforge.net/viewvc/libjpeg-turbo/trunk/java/doc/org/libjpegturbo/turbojpeg/TJ.html</a>), I cannot get the jpeg to load.</p> <p>Here's the error message:</p> <pre> Started turbojpeg.py at Thu Jun 02 12:36:58 EDT 2011 Traceback (most recent call last): File "", line 15, in at org.libjpegturbo.turbojpeg.TJDecompressor.decompressHeader(Native Method) at org.libjpegturbo.turbojpeg.TJDecompressor.setJPEGImage(TJDecompressor.java:89) at org.libjpegturbo.turbojpeg.TJDecompressor.(TJDecompressor.java:58) at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:210) java.lang.Exception: java.lang.Exception: tjDecompressHeader2(): Could not determine subsampling type for JPEG image </pre> <p>So it appears that either libjpeg-turbo cannot read jpeg with alpha as saved by ImageIO, or there is a very non-obvious setting in the call to "decompress" that I am unable to grasp.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload