JPG Thumbnails

Hi!
I've searched the net for information on how to read the thumbnail
image that many JPG files have embedded into them. No success until
now. Can somebody help me with a piece of java code (not using any kind
of external library, only JSDK classes, please) I can use in my
application, please ? I'm looking at the javax.imageio.ImageReader API
but I don't know where to start.
Thanks in advance

import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.imageio.*;
import javax.imageio.metadata.*;
import javax.imageio.stream.*;
import javax.swing.*;
import java.util.List;
public class ThumsUp {
    public static void main(String[] args) throws IOException {
        String suffix = "jpeg";
        write(suffix);
        read(suffix);
    public static void write(String suffix) throws IOException {
        File file = new File("test." + suffix);
        URL url = new URL("http://weblogs.java.net/jag/Image52-large.jpeg");
        BufferedImage image = ImageIO.read(url);
        GraphicsConfiguration gc = getDefaultConfiguration();
        BufferedImage thumb0 = resizeImage(image, 100,50, gc);
        BufferedImage thumb1 = resizeImage(image, 200,100, gc);
        BufferedImage thumb2 = resizeImage(image, 75,75, gc);
        List thumbs = Arrays.asList(new Object[]{thumb0, thumb1, thumb2});
        IIOImage iioImage = new IIOImage(image, thumbs, (IIOMetadata)null);
        Iterator writers = ImageIO.getImageWritersBySuffix(suffix);
        if (!writers.hasNext())
            throw new IOException("no writers for "+suffix);
        ImageWriter writer = (ImageWriter) writers.next();
        ImageOutputStream out = ImageIO.createImageOutputStream(file);
        writer.setOutput(out);
        writer.write(iioImage);
        writer.dispose();
    public static void read(String suffix) throws IOException {
        File file = new File("test." + suffix);
        Iterator readers = ImageIO.getImageReadersBySuffix(suffix);
        if (!readers.hasNext())
            throw new IOException("no readers for " + suffix);
        ImageReader reader = (ImageReader) readers.next();
        ImageInputStream in = ImageIO.createImageInputStream(file);
        reader.setInput(in);
        System.out.println("supports thumbs = " + reader.readerSupportsThumbnails());
        System.out.println("has thumbnails = " + reader.hasThumbnails(0));
        int numThumbs = reader.getNumThumbnails(0);
        System.out.println("numthumbs = " + numThumbs);
        BufferedImage[] thumbs = new BufferedImage[numThumbs];
        for(int i=0; i<thumbs.length; ++i)
            thumbs[i] = reader.readThumbnail(0, i);
        BufferedImage original = reader.read(0);
        JFrame f = new JFrame("X");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container cp = f.getContentPane();
        cp.setLayout(new FlowLayout());
        JLabel imLabel = new JLabel(new ImageIcon(original));
        imLabel.setBorder(BorderFactory.createTitledBorder("original image"));
        cp.add(imLabel);
        for(int i=0; i<thumbs.length; ++i) {
            JLabel label = new JLabel(new ImageIcon(thumbs));
label.setBorder(BorderFactory.createTitledBorder("thumb #"+i));
cp.add(label);
f.pack();
f.setVisible(true);
public static BufferedImage resizeImage(BufferedImage image, int maxW, int maxH, GraphicsConfiguration gc) {
int w = image.getWidth(), h = image.getHeight();
double ratio = Math.min(maxW / (double) w, maxH / (double) h);
int newW = (int)(w*ratio), newH = (int)(h*ratio);
BufferedImage result = gc.createCompatibleImage(newW, newH, image.getColorModel().getTransparency());
Graphics2D g = result.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.drawRenderedImage(image, AffineTransform.getScaleInstance(ratio, ratio));
g.dispose();
return result;
public static GraphicsConfiguration getDefaultConfiguration() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.getDefaultConfiguration();

Similar Messages

  • Since installing CS6, jpg thumbnails viewed in Bridge lack color depth and contrast. When opened in

    Since installing CS6, jpg thumbnails viewed in Bridge lack color depth and contrast. When opened in Photoshop, the color and depth is normal. How can I correct the issue in Bridge? I have emptied my Cache and that has not corrected thed issue. Thanks to anyone who can help!

    Unless using embedded thumbs, you need to set your ACR defaults, and make uncheck auto settings in preferences/camera raw.

  • In Bridge CS6 when I view a jpg thumbnail color loss

    In Bridge CS6 when I view jpgs as a thumbnail and also when selected to single viewing, the colors wash out.  They do not in raw or psd versions of the same photo.  They look fine in windows picture viewer and I saved them to my website and they were fine, bridge is the only place they look washed out.  How do I fix that?

    That means that those JPEGs are untagged, meaning they do not have an embedded color profile.  In the case of untagged files, Bridge assumes the image was created in the sRGB color space.  Obviously, your files must have been created in a different color space but Bridge can't tell which color space that was because you stripped the profile when saving the JPEGs.

  • Syncing JPG Thumbnails to individual MP3s

    Hi All,
    I have a presentation to make and deliver to a number of people. What I want to do is have several MP3s of a speech and connect JPG/PNG thumbnails to them similar to that of album thumbnails. The final delivery device is for iPods. How could I provide the JPGs and MP3s to people without them having to open itunes, drop each respective thumbnail into each track (as an album thumbnail) and then sync it to their ipod in order to see the images when they play it back on their iPods? If I do the above in iTunes myself, and export MP3s will it "bundle" the jpgs with it?
    Thanks
    Cent

    Thanks for the advice but it didn't seem to work
    I've decided to try ditching iPhoto and orgainising, syncing my photo's to all devices from Aperture
    I have so far imported over 1200 photo's (relocating and renaming the master files as well) and find that when syncing through iTunes only 209 photo's are listed. The Projects/Albums are there but some indicate that there are 0 photo's in them when I know other wise (at least according to whats happing in Aperture)
    I'm starting to suspect it may be a computer problem
    Any thoughts?
    Regards
    Mark
    PS: Just after posting this I restarted my computer, went into iTunes and my Apple TV started to sync. It was now syncing 854 photo's not 209 as before.

  • Bridge sometimes won't show jpg thumbnails

    Sometimes when saving a photo from ACR as a JPG, Bridge won't show the thumbnail.  It seems a random thing for some show and others don't.  If I click on the thumbnail it will open in PSCC.  Then save as a TIFF and it shows.  If I change it back to a JPG, then it shows up.  Anyone have any idea why this is happening?
    Thanks,
    Sue

    It is a cache problem. If it happens again choose the thumb icon and with right mouse click menu choose 'purge cache for selection' then it will build a new thumb and it shows correctly.
    If it happens in one folder choose the folder and in menu tool / cache choose 'purge cache for folder'.
    If happening on multiple folders even a purge of central cache is needed either in preferences or on start up holding down option(Mac)  or control (Win) key and choose this option from the menu that shows.

  • Content viewer white thumbnail instead of uploaded jpg thumbnail

    When viewing my folio with Adobe Content Viewer running ios 6, I can seen the desired thumbnail image that I uploaded. However, when I view the same folio downloaded to an iPad running ios 7, there is a blank white icon where the uploaded jog should be. Please help!!!

    Hi Bob,
    When I launch the Adobe Content Viewer App on my iPad, I arrive at the content viewer homepage. This is the icon I am referring to. It is the Visual icon (thumbnail) for my folio.
    To recap, I can see it on an iPad running ios 6, but not on an iPad running ios 7.

  • Can anyone help with PSE8 JPG thumbnail/polygon lasso issue

    Hi, I'm hoping someone can help me here please? When I am in the editing mode of PSE8 and using the polygon lasso tool, after a couple of clicks around the image, the app seems to freeze and only resume when I click outside of the PSE8 window! I attempt again and again but same thing happens.
    Also I've discovered, I can't view thumnails in Windows 7 folders. I mean, when I try to open an image on my laptop, I can't view what the thumnails are, I have to go by title underneath, although image does appear at base of 'Open' window.
    COuld this be a RAM issue, as since updating I keep getting window stating RAM is getting low, yet I've got loads of available RAM!
    Oh dear...HELP!
    Thanks

    Try the workaround in this thread:
    http://forums.adobe.com/message/4134666#4134666

  • Jpg Previews/Thumbnails are washed out

    My jpg thumbnails and previews look washed out in the folders of Windows explorer, but are correct and vivid when I open them in Photoshop. This only happens with files I edit, and has started since updating to the Creative Cloud CS6. How can I get the thumbnails to match - I am concerned about client impressions when seeing them on their systems. I have checked all of the export and color settings I can think of, but can't seem to get them accurate. Any help would be appreciated!

    It's clear that your intent is to save the images with the Adobe RGB profile, and that's perfectly reasonable (and it sounds as though you understand what that can mean to the recipients) but you should double check as changing to a new version of Photoshop will necessarily have meant that you should revisit all your settings.  Double check that when you're saving your image from Photoshop the ICC Profile box is indeed checked.
    I don't believe the installation of Photoshop should change the way thumbnails are handled in Explorer as Adobe doesn't provide any codecs, but it might possibly have something to do with a setting in your File Handling preferences...  Try changing your File Saving options to never save Image Previews.  I've never quite figured out what that setting means in the Windows environment for most file types, but I have completely disabled it and everything works for me.  It's kind of a shot in the dark, but disabling that setting might trigger Windows Explorer to generate the thumbnails itself, and as far as I know that process IS color-managed.
    If you'd like to post one of the images here, I can check that the image is properly tagged with the Adobe RGB profile, though you can certainly check that yourself as well.
    It does open up in every jpg viewing program looking the way it should.
    Oh, and just to clarify a minor point you made, not every viewing program out there is color-managed.  It is possible you may personally find those that are not doing color-management at all to seem to be functioning correctly with your Adobe RGB images because you have a monitor with a gamut similar to Adobe RGB.  The level of implementation of color-management amongst various Windows application is all over the map.  I do know that the Windows 7 Photo Viewer is color-managed as long as you run it in a Window.
    -Noel

  • Thumbnail Images in FCS

    Hi all,
    I've been scratching my head (or more recently, beating it against my keyboard - fortunately they now make them in aluminium, good for the company's expenditure, bad for my head), trying to create some nice quality .jpg thumbnail stills through FCS. I just cannot seem to get them to come out the way I want them to, and I find the settings to be about as user-friendly as an alarm button, hidden behind bullet proof glass, with a sign saying "break glass to sound alarm".
    *What I want to achieve:*
    I need to create thumbnail images of about 50,000 video clips. These need to go on our website, and should be .jpgs sized at 200x113. Also, the source (dv clips) should be cropped a few pixels, to eliminate that nice fuzzy dv edge. These should then end up on our site via FTP (this last bit, I reckon I can do).
    *How I've been failing to do it*
    I think it's something to do with the parameters I'm using. Here's what I've been doing thus far in Administration>Transcode Settings>New preset>Parameters:
    Source Pixel Aspect Ration: Pal 16x9
    Source Offset: 3/2 (is this cropping?)
    Source Image Size: -blank-
    Destination Pixel Aspect Ratio: Square (HD)
    Image Size: 200/113
    Framce Size: -blank-
    Offset: -blank-
    Frame Number: 1
    Rotate/Flip: -off-
    The images that are produced are, well, quite nasty little things that are the wrong shape and sized and uncropped. I've looked in the documentation and can't seem to find what the above parameters mean.
    Any help and guidance would be very much appreciated.
    Ben
    Message was edited by: BenKellySkyworks

    Crystal does not have the bility to use thunbnails. But that would be a great enhancement. I'll add it to the Enhancement request database.

  • Can a Photo page be used as thumbnail links to movie pages?

    I've made a photo page with say 20 or so photo thumbnails. I have made separate movie pages for each movie. Dragged each movie page link to the related picture on the photo page and sized the button to be the same size as the thumbnail image. Checked that the button is linking to the correct movie page.
    In iWeb, when I "make links active", everything works properly. But once it's uploaded, the thumbnails/buttons, when clicked, open up a new browser window with just the jpg thumbnail.
    Any ideas to get this to work? Or do I have to start over, and lay it all out maually?
    G5 DP 1.8 & PowerBook G4 15"   Mac OS X (10.4.6)  

    I think the problem may be related to the Photo page template. When you click on the thumbnail, I think there is some built-in functionality to open a new slideshow window or something.
    Instead of using the Photo gallery template, try using a plain page...one of the templates with as few elements as possible...maybe the movie template. Then manually add your movie thumbnails and size them to your liking. then add the hyperlinks to your movie pages to each thumbnail. I think you might find that this works better.
    ==> www.DirtDoog.com <==</a>    
    Place A Virtual Pin On Putt-Putt's GuestMap!

  • Finder Not Showing Thumbnail Images anymore

    Finder has stopped showing thumbnails of all images, in thumbnail view. Just the generic jpg thumbnail appears. Checked view settings, they are fine. Happens in every folder and on external drives.

    Just like Windows!! Restart fixed it!! Gong!

  • Preview thumbnails (CR2) does not show in import dialog box

    When I import files from my camera ("Import photos from device..."), i don't see preview thumbnails of CR2-files so that I can choose which pictures to import. I can only see gray boxes. JPG thumbnails show.
    I tried to download and install the Canon RAW codecs for Vista  (http://www.canon-europe.com/vista/eos/raw_codec/), but it didn't help.
    Appreciate all help with this problem.
    Nils Öhman
    Equipment:
    Canon EOS 400D
    Adobe Photoshop Lightroom 2.4
    Windows Vista SP2, Swedish version
    HP EliteBook 8530w

    the RAW Codecs for Vista have no effect on Lightroom which should handle and preview files from a 400D without any issues . There may be a problem caused by the fact that you are downloading via your camera rather than from the card. I would suggest using a card reader rather than downloading from your camera.

  • Best way to group TIFF + JPEG + thumbnail versions of the same file

    Cheers - quick question. At work, our photography group delivers photographs in groups of FOUR files per image: high-resolution TIFF; high-res JPEG; low-res JPEG; thumbnail. Is there a native way or feature in Aperture that allows me to group all four versions of these files into a single "bucket" within a project?
    For example, if a have a project holding all the photographs I took during a test flight today, rather than seeing the same image four times consecutively (TIFF, hi-res JPG, low-res JPG, thumbnail), can I simply group those four into one? . . . or, alternately, is there a quick feature within Aperture that makes it very very easy to export a thumbnail or high or low-res JPEG if I choose to only store the high-resolution TIFF?
    I apologize if asking a basic question. I've only been using Aperture for a month - absolutely love it, and have completed most of Apple's video tutorials and the entire "Exploring Aperture" guide, but haven't found anything there addressing this topic.
    Appreciate any insight - or your own personal approaches - that anyone can offer!
    thanks!!
    Mark

    The other possibility would be to use albums. You could create an album for each grouping and then drag the images into the album.
    While this sounds storage intensive (multiple albums all duplicating images in projects) it really isn't given the Aperture way. That is the images in the albums are only links back to the project images. noting is duplicated. The album way might give you a bit more flexibility over stacks. Stacks are good for some things but they can be somewhat rigid in that all the images in the stack, in general, have to move together.
    As you will discover, there are many ways to accomplish the same thing in Aperture. This makes it both extremely powerful and also somewhat frustrating at least at first.

  • How to export square thumbnails from Lightroom

    I`m using Lightroom to export selected photos to my website and i would like to know how to setup export dialog to make JPG thumbnails 120x120 pixels regardles of their size/orientation.

    I may be mistaken, but I don't believe you can. Most you can do is something like make a Virtual Copy Collection of the images, do a Square crop and then export.
    Don

  • Video Thumbnail generator

    I am trying to find a way to create a playlist of videos
    uploaded to a website. What I am trying to find out is, does Flash
    Media Server have a component that when a video is uploaded it will
    generate on the fly a jpg thumbnail of that video? What I am trying
    to do is create sometime (on a much smaller scale) as youtube. Will
    purchasing Flash Media Server help me accomplish that? Or does
    anyone know how youtube created their thumbnail images of the
    videos?
    Thanks

    No... FMS does not have such capabilities. You would need to
    use a program like ffmpeg to handle the thumbnail generation ( see
    article for example:
    http://www.db75.com/blog/archives/000176.html
    ). I would imagine youtube does something similar.
    You can also show the first frame of a video with
    actionscript on the client side, by loading the video and stopping
    on the first keyframe.

Maybe you are looking for

  • Waiting for udev uevents to be processed hangs for 30s. |SOLVED|

    Hello. This is my first post. Just installed ArchLinux with KDE 4.7,everything is working perfectly but something is really annoying. When booting up the laptop (toshiba satellite) it takes too much loading this "waiting for udev uevents to be proces

  • SSM 10.1 - Detail View

    Hi SSM 10.1 Experts, for people who have worked with this SSM 10.1 Version, I want to ask you if it is possible to insert and read comments in the KPI review in the Detail View, it is along a flow, I mean, to read other people comments who have alrea

  • Macbook air heats up after upgrade to Maverix

    After I upgraded to maverix, in sleep mode macbook air heats up too much and battery drains.

  • Programs Keep Freezing, Why?

    I just got the mid-priced macbook because my iBook g4 crashed 2 weeks ago. I transfered all of my files over and have not been having much luck with this little guy. I get no mooing or whine, and the CoreDuoTemp indicates that it runs at acceptable t

  • ICloud emails me every time ical is updated

    Everytime I update, add, delete, or do anything in iCal ( which is synced to my macbook pro, iPhone, iPad,  I get an e-mail notification.   How do I turn this off?