Find format of an image

Hi,
I'm looking for finding the format of an image file (or stream) : tiff, jpg, gif, png, bmp, ...
I don't want to use the extention name (.jpg, .tif, ...), but the contain of the file himself.
how can I do it with JAI (without JDK 1.4) or an other java librairy please ?

See http://gd.tuwien.ac.at/opsys/linux/java/JAI/1.0.2/i386/?file=jai1_0_2-beta-sample-linux.tar.bz2&type=listing

Similar Messages

  • How to find format of an image when its byte[] content alone is available?

    Hi,
    I'm working on code that gets an image content as input in byte[] format. With no other further details provided, how to identify the format of the image contained in the byte array? Specifically, I would like to know if the image contained in it is a PNG, JPG, BMP, etc.
    Image or ImageIO API does not seem to provide a means to do this. Is there a way how this can be achieved?
    Thanks in advance.

    The ImageIO class does provide a way to do what you want... it just takes a couple of steps. Take a look at the determineInputFormat() method below:
    import java.io.ByteArrayInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Iterator;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.stream.ImageInputStream;
    public class ImageFormatTest {
       private static final String IMAGE_PATH = "... PATH TO IMAGE HERE ...";
       public static void main( String[] args ) {
          try {
             final byte[] imageBytes = readImageBytes( IMAGE_PATH );
             final String imageFormat = determineImageFormat( imageBytes );
             System.out.println( "Image format is " + imageFormat );
          } catch (Throwable ex) {
             ex.printStackTrace();
       private static byte[] readImageBytes( String imagePath ) throws IOException {
          final File imageFile = new File( imagePath );
          final byte[] buf = new byte[ (int) imageFile.length() ];
          final FileInputStream fStream = new FileInputStream( imageFile );
          fStream.read( buf );
          fStream.close();
          return buf;
       private static String determineImageFormat( byte[] imageBytes ) throws IOException {
          final ByteArrayInputStream bStream = new ByteArrayInputStream( imageBytes );
          final ImageInputStream imgStream = ImageIO.createImageInputStream( bStream );
          final Iterator<ImageReader> iter = ImageIO.getImageReaders( imgStream );
          final ImageReader imgReader = iter.next();
          return imgReader.getFormatName();
    }

  • Find ths format of an image

    Hi,
    I'm actually triing to create an Java (JSP/Servlet) web-app witch di that :
    Read a temp file (per example Lds2456.tmp) witch is an image, but the suffix do not say the format of the image (it's ".tmp", NOT ".jgp", ".gif",....).
    I would use javax.image (not JAI), to find ths format of the ".tmp" file. Too, after, change is name in the right suffix name (switch the format, like ".png", ".tif", ".jpg",...) too use it in a JSP page (using HTML tag <img src="myImageURL">).
    Can some one help me ?

    Nobody see !?

  • Supported Image formats in af:image?

    Could anyone pls. list which Image formats - the af:image component supports?
    I can't find it listed anywhere,
    Thanx in advance,
    Henrik

    Unfortunately - using jpg - is not an option - due to external requirements.
    Are there another ADF component/construction I can use - to getting ti tiff shown?
    Rgds, Henrik

  • In my Macbook Pro finder folder under All Images, there are duplicate files, but one is small and the other is full size. I wanted to clean up the files, but don't know why I have two of everything. Any Ideas?

    In my Macbook Pro, the Finder folder has duplicate images in the 'all images' file. One image is small and the other is full size. First question is why do I have two of every image? Why is one small and the other large. Do I need two of everything? If not, which do I delete?
    thanks, Jean

    Hello fane,
    Re: duplicate images in finder.
    Nearly all images are JPG with a few GIF and PNG sprinkled in.
    I opened the inspector so I do get info when opening each image, but it a slow process.
    It seems that one image is around 70k while its twin can be up to 4Mb which is what comes unedited from my camera. Sometimes there will be 3 or 4 identical images in finder, but when I open iPhoto to see what ‘s really in the file, I find only one image, and it’s full sized.
    Are all these extra images, even if they are aliases, taking up space on my drive? And should I delete them? The info bar says I have over 10,000 images, which is rather a lot  for what I do.
    I am unable to add the file size on the view menu as it is grayed out. Don’t know why it’s gray, but having that info on the screen would save a lot of time and fiddling with each image.
    I am trying to resize selected pix so I can upload them to e-bay, which requires less than 70k. I have looked at resizing programs but most are for PC platform and not Mac, so I am trying to resize in the finder window under tools. Tedious at best. Any suggestions will be appreciated
    Thanks for your help,
    jeanfromwilsonville

  • How can you find out an individual image size from multiple images on a canvas

    This is probably a really really simple question but I can't for the life of me find how I can find out an individual image size from multiple images on a canvas. eg I have 3 photos i want to arrange 1 large and the other two next to it half the size. How can I edit individual image size on the canvas as when I select the image on a sperate layer I want to resize it just resizes the entire canvas and not the individual image
    Thanks

    I want to know they exact dimensions though. You can get them by dragging to the 0,0 corner and then reading off of the ruler scale on the sides but its fiddily as you have to zoom right in and work it out. I know in photoshop there is a ruler but is there any other way in Elements?

  • As I can sometimes do, I did not read the directions before delving into LR.  Now I find my self with image history in LR on 2 or 3 of my HD's.  I would like to now consolidate it on one HD but fear in doing so I will lose the images I have created within

    As I can sometimes do, I did not read the directions before delving into LR.  Now I find my self with image history in LR on 2 or 3 of my HD's.  I would like to now consolidate it on one HD but fear in doing so I will lose the images I have created within LR.  Is there a tutorio or some other way to get me back on track with this application?

    Your image history (if I understand you properly) is stored in your catalog file, and nowhere else, and so it is only on a single drive.
    Do you mean you have edited photos on multiple drives? This isn't a problem for Lightroom at all, the software doesn't care, and you can leave things just the way they are. But if it bothers you for some reason, you can move the photos to a single drive if you want. In Lightroom select the desired photos or folders (it's easier to do this using Folders) and drag them to the desired drive.
    Alternative if you will be moving lots of folders: Adobe Lightroom - Find moved or missing files and folders

  • Need help with adding formatted text and images to Crystal Report?

    Here's my scenario:
    I have a customer statement that's generated as a crystal report and that has a placeholder for advertisement. The advertisement is mixture of formatted text and images. Until now we only had one advertisement that was always used on the report. The new requirement is that we would have a pool of hundreds of advertisements and would need to display one specific advertisement on the customer statement based on various marketing criteria. They key is that the advertisement content will be determined programmatically and cannot be hardcoded into the report. I'm using Crystal2008 with .net SDK.
    Here are the solutions I thought of, but I'm still rather lost and would appreciate your help/opinion.
    1) Pass HTML or RTF to the report
    Not really sure if this is possible and how to get it done. Also how would I pass in images? Would display formatting be reliable when exporting to PDF?
    2) Create each add as a subreport and append it programatically
    I actually have this working, but I only know how to append a new section to the end of the report and then load the subreport to the section. I have no other controll of the placement. Is there a way to dynamically load a subreport to a predefined section in the main report? How about adding a dummy subreport in the main report as a placeholder and then replacing it with a different subreport? How could I do this?
    3) Pass an Image to the report
    I would create each advertisement as an image and then would somehow add the image to the report. How would I load the image and control the placement? Could I somehow define a placeholder for the image in the main report-maybe a dummy image to be replaced?
    Thank you.

    Hello Pavel,
    I would got the third way.
    You can use dynamic images in your report.
    Just by changing the URL to the image the image can be changed.
    Please see the [Crystal Manual|http://help.sap.com/businessobject/product_guides/cr2008/en/xir3_cr_usergde_en.pdf] and search for images.
    or directly here
    [Setting a Dynamic Graphic Location Path on an Image Object|https://boc.sdn.sap.com/node/506]
    [Dynamic image and HTTP://|https://boc.sdn.sap.com/node/3646]
    [codesample for .NET|https://boc.sdn.sap.com/node/6000]
    Please also use
    [Crystal Reports 2008 SDK Documentation and Sample Code|https://boc.sdn.sap.com/developer/library/CR2008SDK]
    [Crystal Reports 2008 .NET SDK Tutorial Samples|https://boc.sdn.sap.com/node/6203]
    Hope this helps
    Falk

  • In Finder I have many images

    I have 10,000 images & documents(if you click on the finder icon & go to images or documents) on my computer - my question is:  can I delete these? Some I do not know how they got there.
    Or do I just leave them alone.  Some of the documents are gobeldy goop!
    thanks
    Dawne

    Unless you have a space problem, leave them. Only delete stuff when you know what it is, and are sure you don't need it.

  • Where does time machine store content that would be found in the Finder window under "All Images, All Movies, All Documents"? Also, I have many Garageband projects and mp3 files I can't find.

    Where does time machine store content that would be found in the Finder window under "All Images, All Movies, All Documents"? Also, I have many Garageband projects and mp3 files I can't find.

    Easiest way to find time machine files is to open up the folder or application(works for email and iphoto)  they were in - then click on time machine ICON or enter time machine from the time machine menu to go back through the files.

  • Finder doesn't show image dimensions

    Hi!
    I have a problem with image dimensions in Finder. Finder doesn't show image dimension info in preview column and Get Info window. But when I open in Preview app I can see dimensions in Get Info window. How to solve this problem. If I want to sort images by dimension, I can't do that. Because Finder doesn't know image dimensions. You can see images below.

    Terence Devlin wrote:
    That's because the Finder is a file manager and works from file metadata. The data you're seeking is about the file contents. You need to use a Photo Manager or Browser.
    There is someone who can sort images by dimensions and see dimensions in list view. Also if Finder will not show image dimensions, why give me "Dimensions" and "Resolution" option to select in list view.
    VikingOSX wrote:
    Launch a Finder window. Press command+J, and set Show Item Info. Now the image dimensions will show below each image icon. If it is a movie, then the duration of the movie is shown.
    I have done this. But doesn't show information.

  • Finding and deleting unused images

    There's got to be an easy way to find all the unused image
    files (or any other type of file) so that they can be managed - in
    my case deleted. I'm trying to clean up my site - getting rid of
    unused files. I had a lot of selections for images but used only a
    small portion of them. I know if I go one-by-one and delete items
    it will tell me they're linked. But I have aprox 100 unused files
    so I'm looking for a way to automate it. Like in Flash - there's a
    usage count.
    help?
    thanks, Dave

    On Tue, 24 Jun 2008 14:13:59 -0400, E Michael Brandt
    <[email protected]> wrote:
    >
    >> Site | Check Links
    >>
    >> then look at orphaned files in the results panel
    >
    >Careful though. For example if you call some images via
    the Open
    >Browser Window behavior AND their Links are "#" or
    "javascript:;", then
    >those images will be reported as orphans when they are
    not. Not sure
    >also if images used only by CSS styles are reported as
    orphans.
    >
    >Safest is to be certain you have a good off-site backup
    before deleting
    >the files reported as orphans.
    >
    >--
    >
    Yes indeed - Adobe need to do some work on this feature - it
    reports
    my php include files as orphans too !.
    ~Malcolm~*...
    ~*

  • LR3: "Find file" when locating images error?

    When moving images from a portable drive that i use when on the road, i wish to copy them to my harddrive back at home (copy, not "drag & drop move" from within LR3 library modeule, as i wish to keep them on the portable drive).   Within LR2 i would then unplug the portable drive, use "Show in Finder" and then "Fnd Image" (ensuring that "Locate Nearby missing images" is on) and that then makes the connection to all of the images in that folder on the main drive at home.
    The only problem is that so far in LR3, this system of finding individual images does not appear to be working - i can click all the way thorugh to the image on the central home drive, but when clicked, it does not make that connection.
    "Find folder" works ok, but not if you have images from seperate occasions in there, then it can't work; only "Find Image".
    Has the process changed for LR3?  Any suggestions please as a 10 second job, now requires 1+ hour to copy between folders, drag and dropping then re-copying.
    Thanks

    That's a bug in LR 3.0 that was fixed in LR 3.2RC, as far as I can tell.
    The only problem is that so far in LR3, this system of finding individual images does not appear to be working - i can click all the way thorugh to the image on the central home drive, but when clicked, it does not make that connection.
    The workaround is to click the question mark icon on the thumbnail instead if clicking "Show in Finder" from the pop-up menu. This way you avoid the bug.
    Also, why not try installing LR 3.2 RC to check if it solves the problem when clicking "Show in Finder" and subsequently "Find Image".

  • HT5361 IN OS 10 where can one find the folder for images that came with email?

    IN OS 10 where can one find the folder for images that came with email?
    I wish to delete the leftover image files to free up drive headroom.

    I checked in this place, no dice!
    Home/Library/Mail Downloads, or
    the system "Downloads" folder

  • What is the best format to import images into iBA? How should I compress my images before importing? What is the best file format? PNG? Jpeg?

    What is the best format to import images into iBA? How should I compress my images before importing? What is the best file format? PNG? Jpeg? I'm trying to figure out the best file format / compression for importing images into iBA. Also, does anyone know how iBA will compress the file? Are the assets attached (like a website) or flattened out? Does anyone know how iBA handles this? Many many thanks to anyone with insight into this.

    This question is largely answered by the following thread...
    https://discussions.apple.com/message/17805700#17805700

Maybe you are looking for

  • Handling Unit creation

    Dear Friends, I am able to create the Handling Units using BAPI_HU_CREATE but not able to assign the HU to delivery. I can see the HUs are created in VEKP tables correctly. I am using the FM 'HU_ASSIGN_HUS_TO_OBJECT' to assign this to delivery ( LIKP

  • How to install Windows 7 Pro 64bit from a Retail DVD

    Good afternoon I have got a Lenovo X201 which unfortunately cannot locate a recovery disc I mtherefore purchased a retail version of Win7 Pro 64 bit and put into my external DVD player to install I changed the boot option to look at the wxternal dvd

  • Query sharepoint online sites

    Hi, That is my problem http://stackoverflow.com/questions/28991715/list-files-and-folders-in-office-365-sharepoint-site http://stackoverflow.com/questions/27226995/retrieve-sharepoint-site-collection-list-using-restful-api-in-office-365 http://sharep

  • How do I get rid of this Skype p

    There was a horrible Skype update and now Skype sucks.... I want to downgrade to a previous version (6.21). How do I do this? Solved! Go to Solution.

  • Calling overideen method in constructor

    Hi , I want to know why is the overiden method of subclass is called from super class constructor,below is the code import java.util.*; class Super{      // Broken - constructor invokes an overridable method      public Super(){           overrideMe(