Image width/height  without loading file into JVM?

How do we find the width/height of an image, without loading the image into the JVM? Also it would be nice to to obtain the height/width without creating any new objects(from which i would obtain the height and width).
Thanks
Tapan
Edited by: tapanmokha on Jan 27, 2009 8:03 AM

ImageInputStream imageStream =
        ImageIO.createImageInputStream(location);
java.util.Iterator<ImageReader> readers =
        ImageIO.getImageReaders(imageStream);
ImageReader reader = null;
if(readers.hasNext()) {
    reader = readers.next();
}else {
    imageStream.close();
    //can't read image format... what do you want to do about it,
    //throw an exception, return ?
reader.setInput(imageStream,true,true);
int imageWidth = reader.getWidth(0);
int imageHeight = reader.getHeight(0);
reader.dispose();
imageStream.close();

Similar Messages

  • Load Files into stack failing after 1 image

    I've got 2 machines with Photoshop CC, both trying to load multiple images into a stack.  What happens is they load up the first image, and a layer called "load layers" and then it stops, never loading any more than the initial one.
    They're regular .jpg images as far as I can tell, is there anything else that could be causing an issue like this?

    It's completely replicatable, but only with that script, load files into stack, new images, new folder, new user, still doesn't work.  Is this why it's really strange to me.  I have no common ground between the computers as far as I know.

  • LOAD FILE INTO GRAPHIC IMAGE ON CANV

    How do I load file into graphic image on the canvas not the image item on the block?

    With the Layout Editor open, select Edit > Import > Image.

  • Can I modify 'Load Files into Stack.jsx' for custom white balance?

    I've been wondering whether its possible to change Adobe's 'Load Layers in Stack' script so that it loads RAW files with the white balance adjustments I have made in Camera Raw ('ACR').
    At present, the script loads the files as layers with the default ACR (or Lightroom) settings. This means that any white balance adjustments to the file in ACR are ignored and the RAW file is loaded with the WB 'As Shot'.
    It IS possible to save new ACR default settings, but this doesn't really help because I don't want the WB to be a constant value. The changes I make in ACR are usually subtle and 'by eye'.
    I would like the script to be mindful of these changes when opening the RAW file.. does anyone have any suggestions?
    The script is below.
    // (c) Copyright 2006.  Adobe Systems, Incorporated.  All rights reserved.
    @@@BUILDINFO@@@ Load Files into Stack.jsx 1.0.0.1
    // Load Files into Stack.jsx - does just that.
    // BEGIN__HARVEST_EXCEPTION_ZSTRING
    <javascriptresource>
    <name>$$$/JavaScripts/LoadFilesintoStack/Menu=Load Files into Stack...</name>
    </javascriptresource>
    // END__HARVEST_EXCEPTION_ZSTRING
    // debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)
    //$.level = (Window.version.search("d") != -1) ? 1 : 0;          // This chokes bridge
    $.level = 0;
    // debugger; // launch debugger on next line
    // on localized builds we pull the $$$/Strings from a .dat file
    $.localize = true;
    // Put header files in a "Stack Scripts Only" folder.  The "...Only" tells
    // PS not to place it in the menu.  For that reason, we do -not- localize that
    // portion of the folder name.
    var g_StackScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts") + "/"
                                                                                                        + localize("$$$/private/LoadStack/StackScriptOnly=Stack Scripts Only/");
    $.evalFile(g_StackScriptFolderPath + "LatteUI.jsx");
    $.evalFile(g_StackScriptFolderPath + "StackSupport.jsx");
    $.evalFile(g_StackScriptFolderPath + "CreateImageStack.jsx");
    // loadLayers routines
    loadLayers = new ImageStackCreator( localize("$$$/AdobePlugin/Shared/LoadStack/Process/Name=Load Layers"),
                                                                                                          localize('$$$/AdobePlugin/Shared/LoadStack/Auto/untitled=Untitled' ) );
    // LoadLayers is less restrictive than MergeToHDR
    loadLayers.mustBeSameSize                              = false;          // Images' height & width don't need to match
    loadLayers.mustBeUnmodifiedRaw                    = false;          // Exposure adjustements in Camera raw are allowed
    loadLayers.mustNotBe32Bit                              = false;          // 32 bit images
    loadLayers.createSmartObject                    = false;          // If true, option to create smart object is checked.
    // Add hooks to read the value of the "Create Smart Object" checkbox
    loadLayers.customDialogSetup = function( w )
              w.findControl('_createSO').value = loadLayers.createSmartObject;
              if (! app.featureEnabled( localize( "$$$/private/ExtendedImageStackCreation=ImageStack Creation" ) ))
                        w.findControl('_createSO').hide();
    loadLayers.customDialogFunction = function( w )
              loadLayers.createSmartObject = w.findControl('_createSO').value;
    // Override the default to use "Auto" alignment.
    loadLayers.alignStack = function( stackDoc )
              selectAllLayers(stackDoc, 2);
              alignLayersByContent( "Auto" );
    loadLayers.stackLayers = function()
              var result, i, stackDoc = null;
              stackDoc = this.loadStackLayers();
              if (! stackDoc)
                        return;
              // Nuke the "destination" layer that got created (M2HDR holdover)
              stackDoc.layers[this.pluginName].remove();
              // Stack 'em up.
              if (this.createSmartObject)
                        selectAllLayers( stackDoc );
                        executeAction( knewPlacedLayerStr, new ActionDescriptor(), DialogModes.NO );
    // "Main" execution of Merge to HDR
    loadLayers.doInteractiveLoad = function ()
              this.getFilesFromBridgeOrDialog( localize("$$$/private/LoadStack/LoadLayersexv=LoadLayers.exv") );
              if (this.stackElements)
                        this.stackLayers();
    loadLayers.intoStack = function(filelist, alignFlag)
              if (typeof(alignFlag) == 'boolean')
                        loadLayers.useAlignment = alignFlag;
              if (filelist.length < 2)
                        alert(localize("$$$/AdobeScripts/Shared/LoadLayers/AtLeast2=At least two files must be selected to create a stack."), this.pluginName, true );
                        return;
              var j;
              this.stackElements = new Array();
              for (j in filelist)
                        var f = filelist[j];
                        this.stackElements.push( new StackElement( (typeof(f) == 'string') ? File(f) : f ) );
              if (this.stackElements.length > 1)
                        this.stackLayers();
    if (typeof(loadLayersFromScript) == 'undefined')
              loadLayers.doInteractiveLoad();

    This is part of the script looks interesting - is there a reference where can I find more hooks? Perhaps there is one that relates to WB?
    // LoadLayers is less restrictive than MergeToHDR
    loadLayers.mustBeSameSize                              = false;          // Images' height & width don't need to match
    loadLayers.mustBeUnmodifiedRaw                    = false;          // Exposure adjustements in Camera raw are allowed
    loadLayers.mustNotBe32Bit                              = false;          // 32 bit images
    loadLayers.createSmartObject                    = false;          // If true, option to create smart object is checked.
    // Add hooks to read the value of the "Create Smart Object" checkbox
    loadLayers.customDialogSetup = function( w )

  • "Load files into Photoshop layers" fails to complete CS6

    Hi all,
    Hoping someone can help with the folling problem with Photoshop & Bridge CS6
    When in Bridge, after selecting 6 images (CR2) using the command TOOLS>LOAD FILES INTO PHOTOSHOP LAYERS the first file will load into Photoshop, Photoshop will then generate a second blank layer and then read the second file. At this point the "script" will stop. I am left with a document with 2 layers. The top layer has my first image, the bottom layer is empty.
    At this point when I quit Photoshop I am prompted to save this open document which appears to be the only open document. I choose not to save this as a file. I then get a dialogue box prompting to save another open document. Photoshop has loaded the second file to place as a layer but as the "script" has aborted I am left with an open, but invisible file.
    When I first loaded CS6 on Snow Leopard, it would demonstrate this behaviour every time I attempted to run this command from Bridge.
    I did a clean install on a blank HDD of OSX Lion. Installed CS6. The command worked without fail for about a month.
    Then I would get the command aborting occasionally. Restarting Photoshop would let me continue for a few hours before this aborted script problem would happen again.
    Over the last week it has become more frequent, to a point where this workflow is unusable.
    A restart of Photoshop may fix the problem for the next batch of images, only to fail again soon after, or fail on the first attempt after a relaunch of Photoshop.
    A reboot of my computer will allow my to load one or two sets of files before again failing to complete the command.
    I have tried the following:
    In Photoshop preferences:
    disabling the "Use graphics Processor"
    Increasing or decreasing the amount of RAM available to Photoshop
    Changing the cache levels or changing the cache tile size
    changing the scratch disk
    Trashing the Photoshop preferences file (Photoshop Settings.psp)
    In Bridge
    Purging the cache
    Increasing or decreasing the cache size
    Resetting Bridge preferences (holding Command on launch) and deleting all cache files.
    In general system
    Quitting extra programs (Safari, Thunderbird, iTunes)
    Sometimes this will seem to then allow Photoshop to load a full set of images, only to abort again after a few sets.
    Rebooting the computer - again will work for a few images sets before again failing.
    Now the fact that it worked fine for several weeks without presenting a problem would indicate that it is not a bug.
    The fact that is slowly started happening then became more frequent would indicate something changing slowly over time - a larger cache folder perhaps, although purging known Bridge cache folders has not filed the problem.
    Really at the end of my tether here. Even considering downgrading to CS5 - but don't want to have to use the older Adobe Camera Raw.
    System is as follows:
    Mac Pro 2 x 2.66 Quad Core
    24GB RAM
    ATI Radeon HD 4870 512
    OSX Lion 10.7.4
    I have seen a couple of others have posted having a the same problem, both with CS5 and CS6.
    Hoping someone has an answer.
    Thanks.

    Hi JJMack - I just re-read your post. For some reason I thought you were suggesting to make sure "Open documents in Tabs" was selected, it was. Now I realize you were suggesting to turn it off! As another attemp to solve this problem I did de-select it today. Seemed to work for a good while. I was getting very excited, then, on the last set of images I had to do it displayed the same problem. But, it did go for quite a while without failing, and when it did I was thrashing about trying to make another app active. When loading documents like this - with "Open documents in Tabs" de-selected, Photoshop wants to put the loading images as the front-most window, no matter what other apps (Bridge, email, web etc) I click on in the dock. I think it is related to the bug you described effecting the "load files to stack" command.
    Hopefully Adobe is looking at this - mind you, I have read reports of people having this problem in CS5! Looks like that was never resolved sadly.
    I'll keep testing and post back.
    I am looking to upgrade my video card to see if it's a video memory thing.
    What is very weird though is the fact that this problem didn't present itself until after several weeks of working with this command with no problem. No additional apps installed, nothing changed. Why would it start happening only after a while?
    Thanks again for your suggestion.

  • "Load files into Photoshop layers" completely missing from Bridge CS6

    No options to load files into Photoshop layers. Why not, and how can I put several files into one Photoshop layer?
    I'm using Bridge CS6 and Photoshop CC.

    Hi JJMack - I just re-read your post. For some reason I thought you were suggesting to make sure "Open documents in Tabs" was selected, it was. Now I realize you were suggesting to turn it off! As another attemp to solve this problem I did de-select it today. Seemed to work for a good while. I was getting very excited, then, on the last set of images I had to do it displayed the same problem. But, it did go for quite a while without failing, and when it did I was thrashing about trying to make another app active. When loading documents like this - with "Open documents in Tabs" de-selected, Photoshop wants to put the loading images as the front-most window, no matter what other apps (Bridge, email, web etc) I click on in the dock. I think it is related to the bug you described effecting the "load files to stack" command.
    Hopefully Adobe is looking at this - mind you, I have read reports of people having this problem in CS5! Looks like that was never resolved sadly.
    I'll keep testing and post back.
    I am looking to upgrade my video card to see if it's a video memory thing.
    What is very weird though is the fact that this problem didn't present itself until after several weeks of working with this command with no problem. No additional apps installed, nothing changed. Why would it start happening only after a while?
    Thanks again for your suggestion.

  • "Load Files into Photoshop Layers" persistent misalignment problem

    I'm having a persistent problem which technical support was unable to resolve after being on the phone with them for 1.5 hrs.
    I'm working in Bridge CC in ACR, synchronizing all parameters incl. crop, transform, exposure, etc. of a bracketed group of images shot from a solid tripod. When using the Tools / Photoshop / Load files into Photoshop layers command, the images open in photoshop in a layered file, BUT some are knocked out of alignment. Actually they have been cropped slightly smaller than the original file, always by the same number of pixels. Sometimes all layers are affected, sometimes not. Photoshop and Bridge are both up to date, as is the camera raw plugin. I’m on a new iMac i7 4-core, OSX 10.9.4. All software was newly downloaded from Adobe less than two weeks ago. I have reset preferences, even uninstalled and reinstalled Bridge CC 6.1.0.115 to no avail. Any suggestions?

    Hi JJMack - I just re-read your post. For some reason I thought you were suggesting to make sure "Open documents in Tabs" was selected, it was. Now I realize you were suggesting to turn it off! As another attemp to solve this problem I did de-select it today. Seemed to work for a good while. I was getting very excited, then, on the last set of images I had to do it displayed the same problem. But, it did go for quite a while without failing, and when it did I was thrashing about trying to make another app active. When loading documents like this - with "Open documents in Tabs" de-selected, Photoshop wants to put the loading images as the front-most window, no matter what other apps (Bridge, email, web etc) I click on in the dock. I think it is related to the bug you described effecting the "load files to stack" command.
    Hopefully Adobe is looking at this - mind you, I have read reports of people having this problem in CS5! Looks like that was never resolved sadly.
    I'll keep testing and post back.
    I am looking to upgrade my video card to see if it's a video memory thing.
    What is very weird though is the fact that this problem didn't present itself until after several weeks of working with this command with no problem. No additional apps installed, nothing changed. Why would it start happening only after a while?
    Thanks again for your suggestion.

  • MISALIGNMENT PROBLEMS USING "LOAD FILES INTO PHOTOSHOP LAYERS" FROM BRIDGE CC

    I'm having a persistent problem which technical support was unable to resolve after being on the phone with them for 1.5 hrs. I was told the issue would be escalated... That was five days ago, and I've heard nothing.
    Here is the problem: In ACR working on a bracketed group of five images shot from a solid tripod in Bridge CC. I carefully synchronize all parameters incl. crop, transform, exposure, etc. Then I go to Tools / Photoshop / Load files into Photoshop layers, and the images open in photoshop in a layered file..., BUT some are knocked out of alignment. Actually they have been cropped slightly smaller than the original file, always by the same number of pixels. Sometimes all layers are affected, sometimes not.
    Photoshop CC & Bridge CC are both up to date, as is the camera raw plugin. I’m on a new iMac i7 4-core, OSX 10.9.4. All software was newly downloaded from Adobe two weeks ago. I have reset preferences, reset tools in Photoshop, even uninstalled and reinstalled Bridge CC 6.1.0.115 all to no avail. Any suggestions? I am desperate for some help.

    I run Windows 7 Ultimate, I have 2.00GB of RAM with 1.74 usable, and I selected 40 images, each about 2MB.

  • Why while in Bridge Load Files into photoshop Layers does not work?

    In Bridge, Tools>Photoshop>Load Files into Photoshop Layers does not work.  I have two images selected and when I execute that comman in Bridge nothing happens.  I exited and restarted both PS and Bridge and still nothing.  I am working in Windows 7 and Photoshop cs6.

    No I tried File/scripts/load file into stack and still did not work.
    There was an update to bridge and now it works.  Thanks so much.

  • How do you "load files into photoshop layers" in bridge cc

    I am having difficulty following on instruction in learning photoshop cc.
    The book says to load files as layers select(in Bridge) tools/photoshop/Load files into photoshop Layers.
    There is no Photoshop Option in the Tools Menu in my Bridge CC.
    Is ther another way?
    Dave

    I run Windows 7 Ultimate, I have 2.00GB of RAM with 1.74 usable, and I selected 40 images, each about 2MB.

  • PS CS3 extended "load files into stack" question

    Hi,
    I've been trying to use the "Load files into stack" script in PS CS3 extended but the problem is that if for example I have files with these names:
    File_1
    File_2
    File_3
    when I use the script it puts them together but in the wrong order so in my layers they are like this:
    File_1
    File_2
    File_3
    which would be wrong because the File_1 is my first image but it's the last layer so if I make this into a gif file and watch it, it would play backwards.
    I was wondering if there is away to fix this. thanks in advance.
    PS: If there is anything I need to provide to make it easier for you to help me, please ask.

    Thank you jugenjury for your fast replay, but let me explain what exactly I'm doing maybe it helps, I'm not very familiar with PS so I'm kinda confused about what you just said.
    I'm trying to make a .gif from an .avi file. I tried using the File>Import>Video Frames to Layers but I get all blank layers so I used another program to take mass screen shots. so I have 133 images which I want to make into a .gif file. I use the Load files into stack script then in the animation tool I select the "make frames from Layers". It all works out so far but the problem is that the video plays backwards because of the problem I explained in first post.

  • Automate 'Load files into stack' and save as new file

    Hello there,
    I hope someone can help me with the following issue:
    I have 300 folders, each containing 100 images which I need to open as layers, change the opacity to 1% for every layer, flatten the image and then save as a new file. So for every folder I would need one new file generated from the 100 originals.
    I know how to do it manually, i.e. load every folder with the 'Load files into stack' command and let an action run for the rest, but that does take some time with 300 folders. Maybe someone knows how to manipulate the 'load files into stack' script so that it does the job independently.
    Thank you for your answers.

    I think you would be better off starting from scratch with a new script for the design and structure of the 'Load files into stack' script is not easy to comprehend.
    I guess that’s sound advice.
    But another point, leroybak:
    What are you trying to achieve here anyway?
    If you want to »blend a movie into one image« like a continuous exposure of the whole movie on photographic paper (and it has been done) changing all layers opacity to 1% might be not altogether the ideal route.
    Instead converting the Layers to one Smart Object and invoking Layer > Smart Layers > Stack Mode > Mean might be better in that all layers contribute to the resulting values equally.

  • Modify Load Files into Stack.jsx

    I am new to Photoshop Scripting so I am sorry if this has already been answered, but I can't seem to find out the answer or figure this one out.   I am writing a script that is doing an INCLUDE using the Photoshop script Load Files into Stack.jsx.  This script seems to name the layers the Filename.  I would like to figure out how to modify this script to not include the file name in the layer and just put Layer 1, Layer 2.  Any help would be greatly appreciated. 

    That may work, but I am not sure what to put into the script and where (sorry, yes I am new at this, this is my first attempt and Photoshop scripts).  Here is what I am doing and what I have coded so far.  I have created a droplet that would move files over into Photoshop do some reformating of the images and then when I get 4 images into Photoshop I am merging the open documents into a separt document and then kicking it back over to an action to do some more formatting with the combined document.  Here is the code I have so far. 
    var loadLayersFromScript = true;
    //@includepath "/C/Program Files/Adobe/Adobe Photoshop CS5.1 (64 Bit)/Presets/Scripts/"
    //@include "Load Files into Stack.jsx"
    var files = [];
    // declare local variables for close files
    var name = activeDocument.name;
    for(var d =0;d<app.documents.length;d++){
        try{
            files.push(app.documents[d].fullName.fsName);
        }catch(e){
            alert(localize('$$$/AdobePlugin/Exposuremerge/Mustsave=Documents must be saved before they can be merged'));
    if( d > 3 ){
    loadLayers.intoStack(files,true);
    // close documents except Untitled document
    while (documents.length > 1) {
      for (var i = 0; i < documents.length; i++) {
    // close all documents except the active document
      if  (documents[i].name != "Untitled1") {
                  documents[i].close(SaveOptions.DONOTSAVECHANGES);
    doAction("Resize Canvas", "Finish Document");
    The reason I need the Layers to not be names is because the document names change and I can not get the actions to work with the differences in the Layer Names when the new files come in. 
    Any help would be GREATLY appreciated.   

  • Load files into Stack Problems

    So what happen was this. I make GIFs as a hobby. But what happen was that 3 days ago, I opened my Photoshop CS5.1 Extended version 12.1 (x64) and did the usual thing.
    I went to Scripts and to Load Files into Stacks. I loaded my files and pressed OK. So here's the funny part, usually, the pictures will load by itself and eveyrthing will be in order. But what happen was that the layers load to around 6 to 7 layers and everything just disappear. Literally disappear. Like I didn't even load anything. No canvas, no images, nothing. I thought it was a bug or something so I reinstalled my CS5 but the problem remains.
    So I try with my CS6 Extended version 13.0 x64. (That I barely use because I'm still more comfortable with CS5.) And the same thing happens.
    I decided to Google it and nothing comes up. I do not know whether is it my laptop or something went wrong somewhere. This has never happen before for the amount of time I have CS5.
    I even change my scratch disc space. Last time it was on (C) with around 20GB space and nothing happens. So I changed it to my D drive and it has atleast 150GB space. I even tried closing every applications I have to test whether is it something related to my ram. But nothing happens. The problem remains.
    So I require some help because I asked around and it appears that none of my friends knows whats wrong.
    Here's my system information:
    Window 7 Ultimate Service Pack 1
    Intel (R) Pentium (R) CPU B970 @ 2.30GHZ
    6.00 GB Ram
    Running on 64-bit OS
    Graphics:
    Intel(R) HD Graphics Family

    When you start having problems with Photoshop.  Most of the time its because of something external to Photoshop or your user id Photoshop preferences.   Reinstalling Photoshop seldom fixes these problem. For User preferences survive across the reinstall. Third party plug-in may as well. Since you have the problem with both CS5 and CS6 it may have to do with the files your loading into the stack. For that something both version are trying to process.  CS5 and CS6 haves separate Preferences and third party add on must be installed into each though they may share plug-in if you use Photoshop Preferences to and a additional plug-in path and you use the same path for CS5 and CS6.

  • " Load files into stack" Crach photoshop CC since the last update

    Hello,
    I have a probleme since the last photoshop's update... I don't don't know if it's the update is the reason for this crach but I'm used to working with this module often "Load files into stack" but this is the first time since Friday that is photoshop bug and has to be the restart.
    Do you have a solution?
    Thank you in advance

    Thank you JJMack for your reply, sorry for my english.
    This is strange because I have to use this module 2-3 times a day and twice with more of 20 pictures
    I have copy all information for you :
    Version Adobe Photoshop : 14.1.2 (14.1.2 20130923.r.427 2013/09/23:23:00:00) x64
    Système d'exploitation : Windows 8 64 bits
    Version : 6.2
    Architecture système : UC Intel Famille :6, modèle :10, niveau :9 avec MMX, SSE Entier, SSE FP, SSE2, SSE3, SSE4.1, SSE4.2
    Nombre de processeurs physiques : 4
    Vitesse du processeur : 2994 MHz
    Mémoire intégrée : 8064 Mo
    Mémoire libre : 1788 Mo
    Mémoire disponible pour Photoshop : 6990 Mo
    Mémoire utilisée par Photoshop : 70 %
    Taille de la mosaïque d'images : 0K
    Niveaux de mémoire cache de l'image : 0
    Affichage : 1
    Limites d'affichage : haut = 0, gauche = 0, bas = 1050, droite = 1680
    Dessin OpenGL : Activé.
    Anciens GPU OpenGL autorisés : Non détectés.
    Mode de dessin OpenGL : Avancé
    Mode OpenGL normal autorisé : Vrai.
    Mode OpenGL avancé autorisé : Vrai.

Maybe you are looking for