Thumbnails with Java Advanced Imaging

Hi,
I'm trying to create thumbnails from images that I am loading into an application. Scaling won't work as my images may be of different sizes and I want to apply the function to all images.
Any Ideas,
Thanks,
Kieran.

Yes scaling will work. You just have to figure out the scale you need
to use for each image.
check the x and y size of the image. find the longest of these and then
figure out the scale factor needed to get the biggest dimension to fit
the thumbnail.
matfud

Similar Messages

  • How to set color space to JPEG image with Java advance Imaging

    How to set color space to JPEG image with Java advance Imaging.
    is there any API in JAI which support to set color space.

    I'm definately no guru, but this is how you can change it.
    CTRL + ALT + Click on the part of the component that you want to change. This brings up the Hidden Dom Inspector, background of component will be surrounded with a red outline (Make sure the red outline is surrounding the part of the tabset you want to change), Now you go to properties sheet and click the ellipses next to rules property this will pop up a dialog you look in this list (At the top) to see the default style classes that are affecting the rendering of the component outlined in red. (You will be able to select different sections of a single component) then you just rewrite the style class that you want to change in your Stylesheet (You will not find the styleclass that you want to change because it is a part of your theme .jar but as long as you name it exactly the same and place in your stylesheet it will override the theme .jar style classes) it's actually very easy -- you were right should be a piece of cake for a guru. Don't have the link handy but you can check out Winston's Blog on changing Table Formatting to get this information...It is EXTREMELY useful if you want your apps to have a custom look and not default that comes with Creator Themes.
    Hope this helps you out God knows others have helped me alot!
    Jason

  • How to set color depth to Bitmap image with Java advance Imaging

    i have to convert image one format ot bmp format and also set the color depth as 1 bit , 4 bit , 8 bit, 16 bit, 32 bit of image.
    has any one done this before. please help me out .

    Take a look at the example code here: http://forum.java.sun.com/thread.jsp?forum=20&thread=560573&tstart=0&trange=15
    I took an image that was 24 bits/pixel (I guess) and converted it to an indexed color model (8 bits/pixel).
    Is that what you mean? (It's also easy to convert to 16 or 15 bits/pixel: use TYPE_USHORT_565_RGB or
    TYPE_USHORT_555_RGB.)

  • Finding a Gif Encoder for Java Advanced Imaging (JAI)

    I'm trying to find the GIF encoder for Java Advanced Imaging. I keep reading all over the place that there is one, but for the life of me I can't figure out where it is supposed to be. Could anyone please enlighten me?
    Thanks

    After I installed this, it still doesn't report gif as a possible encoding type:
    String[] codecs = ImageCodec.getEncoderNames(img, null);
                for (int j = 0; j < codecs.length; j++) {
                    String codec = codecs[j];
                    System.out.println (codec);
                }only reports the following types available:
    pnm
    jpeg
    tiff
    png
    bmp

  • What's the latest stable version of Java Advanced Imaging Image I/O Tools?

    Hi,
    Could anybody tell me what's the latest stable version for Java Advanced Imaging Image I/O Tools and from where I can download the same?
    Thanks

    Just 'mark out of date' the package. Or email him directly. The forums are generally the WORST way to try and contact any specific developer.
    Oh, and before that, please do a quick google....
    http://projects.gnome.org/gedit/
    Closing.

  • JAI (Java Advanced Imaging) and CF8

    Hi
    I'm using the Java Advanced Imaging API since CF6 and made
    several jar files to manipulate images (as it wasn't integrated in
    CF).
    Today I installed CF8, put the "jai_core.jar" and
    "jai_codec.jar" in the "cfroot\runtime\jre\lib\ext" folder as I did
    when I first developped my application or when I migrated from CF6
    to CF7 but today it does not work.
    I have the following error (see attached), ImageInfo and
    GetTaille are my own jar classe and method.
    I saw that there is already a "jai_core.jar/jai_codec.jar" in
    "cfroot\lib" So I think that there is a conflict between the two
    JAI's. I removed mine, but I have another error : "An exception
    occurred when instantiating a Java object. The class must not be an
    interface or an abstract class. Error:
    com/sun/media/jai/codec/ImageEncodeParam."
    I also tried to replace the JAI of CF8 by mine (just for a
    test) but I have the same error.
    Do you have any idea of a solution ?
    I know I can now use the CF8 tags to manipulate images, but I
    have to rewrite lots of code and I think there is still
    manipulations that CF8 can't handle (CMYK images, ICC profiles,
    Thanks in advance for your suggestions

    > "An exception occurred when instantiating a Java object.
    The class must not
    > be an interface or an abstract class. Error:
    I don't know how you're using
    com/sun/media/jai/codec/ImageEncodeParam in your code but the error
    is clear. ImageEncodeParam is an interface in the CF8
    jai_codec.jar. You can instantiate a concrete class, but not an
    interface. Possibly the private classes have changed since you
    first wrote the jar?
    > I think that there is a conflict between the two JAI's.
    >...
    > Caused by: java.lang.SecurityException: sealing
    violation: package
    > com.sun.media.jai.util is sealed
    You could be right. If the jars are sealed having two of them
    in the classpath might cause that kind of error.

  • JAI(Java Advanced Imaging) Problem with splitting TIFF images

    Hi
    I am getting problem with height when I use this program to split TIFF images
    ImageDecoder decImage = ImageCodec.createImageDecoder("tiff", inStr,
    null);
    Then it creates RenderedImage page by page and encodes them to file:
    String outFileName = "";
    OutputStream outStr;
    TIFFEncodeParam encParam = new TIFFEncodeParam();
    encParam.setCompression(TIFFEncodeParam.COMPRESSION_PACKBITS);
    for (int i=0,n=this.getPageCount(); i < n; i++)
    outImage = this.decImage.decodeAsRenderedImage(i);
    outFileName = "C:\\Temp\\Split" + i + ".tif";
    outStr = new FileOutputStream(outFileName);
    BufferedOutputStream bOutStr = new BufferedOutputStream(outStr);
    encImage = ImageCodec.createImageEncoder("tiff",bOutStr,encParam);
    encImage.encode(outImage);
    bOutStr.flush();
    bOutStr.close();
    }The images are shrinking when I split . I need a solution to this problem.
    Thanks for any help in advance
    Sudheer.

    Hi
    Did you get a solution for your problem. I am also trying to split a TIFF file.
    Thanks in advance
    Antony

  • Java Advanced Imaging - Imaging Client Server application

    Hello,
    I try to send images compressed from a server to a client, the first Image is received by the client, but nothing append after.
    The client send an error that says that the socket connection is closed and I don't know wky !
    I am using "JAI" for the image compression on the server and I use the method ImageCodec.createImageEncoder(OutputStream dst, ImageEncodeParam param)
    OutputStream is the data stream between the client and the server, I have used DataOutputStream and OutputStream object but I got the same error.
    (In an example of JAI they use FileOutputStream, I just change it for OuputStream in order to send data on the socket).
    ImageEncodeParam is null.
    I use an other socket that permits to launch commands through text command. So text commands and data are on 2 differents sockets.
    Every time the client ask to the server for an image and the client wait for the stream data.
    I know that it could be easer using RMI but it will be better for me to use a stream.
    Could you tell me what way should I take, Could you show me an example?
    Thank you in advance,
    Regards.

    This has nothing to do with imaging.
    You are sending something via a socket and that is the problem.
    The most likely problems:
    1. You are sending/reading text not binary.
    2. You are sending data not a message (a message contains data) and thus have no way to determine when the actual message has arrived.
    3. You are just doing something wrong with your socket code.

  • Using Java Advanced Imaging (JAI) in Applet

    I'm trying to port a JAI user interface to an applet using Apache Tomcat. When I try to display an image in the applet I get an exception and I have no idea what the cause is. I've opened up security completely (temporarily) to ensure that I'm not getting an error due to an applet security issue. Consequently, I'm able to browse/open files from the client.
    Here is the stack for the error I'm getting. Can anyone tell me what is causing this error? Thanks.
    Java(TM) Plug-in: Version 1.4.1_01
    Using JRE version 1.4.1_01 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\Administrator
    Proxy Configuration: No proxy
    c:   clear console window
    f:   finalize objects on finalization queue
    g:   garbage collect
    h:   display this help message
    l:   dump classloader list
    m:   print memory usage
    o:   trigger logging
    p:   reload proxy configuration
    q:   hide console
    r:   reload policy configuration
    s:   dump system properties
    t:   dump thread list
    v:   dump thread stack
    x:   clear classloader cache
    0-5: set trace level to <n>
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
         at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1669)
         at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
         at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
         at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:805)
         at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:853)
         at javax.media.jai.RenderedOp.getWidth(RenderedOp.java:2135)
         at com.abi.protmodule.GelDisplayData.getGelImage(GelDisplayData.java:558)
         at com.abi.protmodule.ScrollingGelPanel.<init>(ScrollingGelPanel.java:58)
         at com.abi.ris.web.applet.GelEditPanel.showGelImage(GelEditPanel.java:76)
         at com.abi.ris.web.applet.GelEditApplet.openGelJButton_actionPerformed(GelEditApplet.java:159)
         at com.abi.ris.web.applet.GelEditApplet.chooseFileJButton_actionPerformed(GelEditApplet.java:136)
         at com.abi.ris.web.applet.GelEditApplet$1.actionPerformed(GelEditApplet.java:73)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
         at java.awt.Component.processMouseEvent(Component.java:5093)
         at java.awt.Component.processEvent(Component.java:4890)
         at java.awt.Container.processEvent(Container.java:1566)
         at java.awt.Component.dispatchEventImpl(Component.java:3598)
         at java.awt.Container.dispatchEventImpl(Container.java:1623)
         at java.awt.Component.dispatchEvent(Component.java:3439)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
         at java.awt.Container.dispatchEventImpl(Container.java:1609)
         at java.awt.Component.dispatchEvent(Component.java:3439)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    Caused by: java.lang.NoSuchFieldError: borders
         at com.sun.medialib.mlib.Image.initIDs(Native Method)
         at com.sun.medialib.mlib.Image.<clinit>(Image.java:2903)
         at com.sun.media.jai.mlib.MediaLibAccessor$1.run(MediaLibAccessor.java:223)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.media.jai.mlib.MediaLibAccessor.setUseMlib(MediaLibAccessor.java:220)
         at com.sun.media.jai.mlib.MediaLibAccessor.useMlib(MediaLibAccessor.java:185)
         at com.sun.media.jai.mlib.MediaLibAccessor.isMediaLibCompatible(MediaLibAccessor.java:391)
         at com.sun.media.jai.mlib.MediaLibAccessor.isMediaLibCompatible(MediaLibAccessor.java:314)
         at com.sun.media.jai.mlib.MlibScaleRIF.create(MlibScaleRIF.java:82)
         ... 39 more
    Could not find mediaLib accelerator wrapper classes. Continuing in pure Java mode.

    look at
    http://forum.java.sun.com/thread.jsp?thread=290960&forum=20&message=1261471
    and
    http://forum.java.sun.com/thread.jsp?forum=20&thread=173410
    It's something related with DLL libraries...

  • Saving a Gif image using JAI (Java Advanced Imaging)

    I'm trying to read in and save out a bunch of gif images in JAI. I'm reading them in, resizing them, and then saving them back out, all in gif format.
    For some reason some of my gif images work fine, and some don't throw any errors, but save as 0k size.
    When I do img.getColorModel().toString(); I get the following output for images that do work:
    IndexColorModel: #pixelBits = 8 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@1bbf1ca transparency = 1 transIndex = -1 has alpha = false isAlphaPre = false
    And the following output for images that don't work:
    ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@1bbf1ca transparency = 1 has alpha = false isAlphaPre = false
    If I try to save the images that don't work out as jpg's they work fine, but if I try to save them out as gif's, I get 0k files.
    Any insight on how to correct this problem?
    I assume it has something to do with the 24 numComponents in the non-working gifs, but I'm really not sure.
    Please help.
    Thanks.

    Can you post your image property?
    Try using this for image compression:
    int pixelSize = img.getColorModel().getPixelSize();
    if (1 == pixelSize) {
    tiffEncodeParam.setCompression(TIFFEncodeParam.COMPRESSION_GROUP3_2D);
    } else if (8 == pixelSize) {
    tiffEncodeParam.setCompression(TIFFEncodeParam.COMPRESSION_DEFLATE);
    } else if (24 == pixelSize) {
    tiffEncodeParam.setCompression(TIFFEncodeParam.COMPRESSION_JPEG_TTN2);
    Thanks,

  • Download for Java Advanced Imaging Image I/O Tools 1.0 not working

    Hey there,
    Anyone able to get the JAI I/O package from Sun, whenever I go to download it from
    http://java.sun.com/products/java-media/jai/downloads/download-iio.html
    I get a "FATAL Exception".
    If anyone has a copy of the I/O package and can share it please let me know. I have downloaded the regular JAI API but I do not believe this adds TIFF support.

    I read somewhere (perhaps in the imageio-interest maillist) that
    the native libraries only apply to JPEG and that they aren't strictly
    necessary unless you want the accompanying performance boost. So I've
    been using just the JAR files and NOT the native dll:
    clibwrapper_jiio.jar
    jai_imageio.jar
    mlibwrapper_jai.jar
    But NOT: clib_jiio.dll
    This has worked fine for my application and my applet. I have been using the BMP and TIFF readers with no problem. However, when I bundle these
    JAR files into my Java Web Start application, those readers aren't found. I see the JAR files get loaded and validated (I had to sign each of these JAR files -- could that be a problem?) but my JavaWS application can't read TIFF or BMP. Any ideas?
    Could someone confirm that the JAR files ARE usable without the native
    libraries? Also, in that case, does one need ALL the JAR files?

  • Jave Advanced Imaging

    Dear all,
    I am writing a servlet which can resize and display an image. firstly, it retrieves byte[] data as an image, then if the image size is too big, the image will be resize to a propotional size, say 85% of the original size. but I cannot find any decoder for .gif images.
    Byte[] byteImage = (byte[]) img; // img is an image body and stored in database
    ByteArrayInputStream inStream = new ByteArrayInputStream(byteImage);
    JPEGEncodeParam encodeParam = new JPEGEncodeParam();
    ImageDecoder decoder = ImageCodec.createImageDecoder("JPEG", inStream, encodeParam);
    JPEGEncodeParam can be used to encode a .jpg image byte[] file with ByteArrayInputStream. However, It cannot serve a .gif image byte[] file. Can somebody help?
    Cos

    Thanks first.
    however, i found that Acme.JPM.Encoders.GifEncoder is easier to use.
    but i got another problem:
    when the quality of a JPEG image is not good, when the scale is processed, the color of the image will be discarded or too compressed. what should i do?
    byte[] btImg = image btye[] from database;
    ByteArraySeekableStream inStream = new ByteArraySeekableStream(btImg);
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    RenderedImage imgSrc = JAI.create("stream", inStream);
    ParameterBlock pb = new ParameterBlock();
    // Scale
    pb = new ParameterBlock();
    pb.addSource(imgSrc);
    pb.add(1.50F);
    pb.add(1.50F);
    pb.add(0.0F);
    pb.add(0.0F);
    pb.add(new InterpolationBicubic(1));
    RenderedImage imgRen = (RenderedImage) JAI.create("scale", pb, null);
    JPEGEncodeParam encodeParam = new JPEGEncodeParam();
    ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG", outStream, encodeParam);
    encoder.encode(imgRen);
    //output scaled byte[]
    byte[] btImage = outStream.toByteArray();
    can anyone help?
    otto

  • JAI extension automatic installation fail with Java Plug-in 1.4.1_01

    Hi everyone,
    i have a html page with an applet that use the JAI (Java Advanced imaging) extension. I used to run it with java plug-in 1.3.1_03.
    When the JAI extension was not installed, it was automatically downloaded and installed. I use the sun "Signed Auto Installation for browsers" jar available on the JAI download page.
    But with Java Plug-in 1.4.1_01, it seems to have a security problem. Is the "Signed Auto Installation for browsers" only java plug-in 1.3 compatible or is there a way to install it with 1.4.
    If anyone has encountered the same problem with another extension, it could help me to know how to have it installed automatically with java Plug-in 1.4.
    I tested on IE 4 and 6 on Windows NT4 & IE 6 on Windows 2000, and i have the same results.
    Thanks
    Philippe
    see the following java console output :
    Java(TM) Plug-in: Version 1.4.1_01
    Using JRE version 1.4.1_01 Java HotSpot(TM) Client VM
    Modality popped
    User selected: 0
    Optional package download granted by user, download from http://xxxxxxxxxxxxxxxxxxxxxx/jai_windows-i586.jar
    Connecting http://xxxxxxxxxxxxxxxxxx/jai_windows-i586.jar with no proxy
    Connecting http://xxxxxxxxxxxxxxxxxx/jai_windows-i586.jar with cookie "JIGSAW-SESSION-ID=J986902630-19"
    Loading Root CA certificates from D:\PROGRA~1\Java\J2RE14~1.1_0\lib\security\cacerts
    Loaded Root CA certificates from D:\PROGRA~1\Java\J2RE14~1.1_0\lib\security\cacerts
    Loading JPI certificates from D:\WINNT\Profiles\qpbl\.java\jpicerts141_01
    Loaded JPI certificates from D:\WINNT\Profiles\qpbl\.java\jpicerts141_01
    Loading certificates from JPI session certificate store
    Loaded certificates from JPI session certificate store
    Checking if certificate is in JPI permanent certificate store
    Checking if certificate is in JPI session certificate store
    Checking if certificate is in Root CA certificate store
    Checking if certificate is in Root CA certificate store
    Checking if certificate is in Root CA certificate store
    sun.misc.ExtensionInstallationException: User deny optional package installer to be launched.
         at sun.plugin.extension.ExtensionInstallationImpl.verifyJar(Unknown Source)
         at sun.plugin.extension.ExtensionInstallationImpl.access$100(Unknown Source)
         at sun.plugin.extension.ExtensionInstallationImpl$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.extension.ExtensionInstallationImpl.installExtension(Unknown Source)
         at sun.misc.ExtensionDependency.installExtension(Unknown Source)
         at sun.misc.ExtensionDependency.checkExtension(Unknown Source)
         at sun.misc.ExtensionDependency.checkExtensions(Unknown Source)
         at sun.misc.ExtensionDependency.checkExtensionsDependencies(Unknown Source)
         at sun.misc.URLClassPath$JarLoader.parseExtensionsDependencies(Unknown Source)
         at sun.misc.URLClassPath$JarLoader.getClassPath(Unknown Source)
         at sun.misc.URLClassPath.getLoader(Unknown Source)
         at sun.misc.URLClassPath.getResource(Unknown Source)
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Modality pushed
    Modality popped
    Optional package installation failed.
    Installation successful

    I seem to be having the same problem. If you figured out the solution, can you please post it?
    Thanks

  • Java ODBC image database with MS Access

    hi ,
    Can any one please tell me if it is possible to put and get image from MS Access database with java JDBC ODBC driver? If it is possible then what will be the data type in Access and java. Thanks in advance ��

    I've not seen a data type in Access that would be
    appropriate for iimages--and I believe Access may
    still have an overall size limitation (this may have
    been taken off in Access 2003). If this were Oracle, you'd be using a BLOB. But the reasoning that follows would be the same, regardless of database.
    What I'e had best
    luck doing is leaving the files in their native
    format and storing them in directory structures to
    keep them segregated if need be, and storing their
    names and locations in the DB.This is what I've seen done. It makes little sense to stick the JPEG bytes in the database. You can't use them in a WHERE clause. They just kill database performance. morgalr's solution is a good one.
    %

  • Opening Images With Java

    How do you open images with Java? It is a JPEG, and as most will figure out from this post, I'm new to this. :P thanks in advance for any effort...

    Well... Can you possibly tell me what to put in (eg Source Packages) so yea... I'll look into the tutorial, but I also have another question. Would this work?
    Image img = Toolkit.getDefaultToolkit().getImage(C://desktop/[gamefolder]/[hiddenimages]/[image]);
    When [gamefolder] is the name of the folder, [hiddenimages] is the sub-folder with the images in it, and [image] is the image...

Maybe you are looking for