How do I determine the size of an image ( bytes not dimensions )?

I am working on an application which downloads images from the web and caches them for speed reasons. I want to allow the users to browse the cache and dump selected images to free up memory. Ideally I would display the image size in bytes for each cache entry, but I haven't seen any way to access this info.
I do not want dimensions. getIconHeight() * getIconWidth() doesn't address bit depth at all, which can make a huge difference. If there was some getBytes() method I could use that, but I haven't found one yet.
Help?

Only if you use a stream and count the bytes. I'm loading it like this:
ImageIcon foo = new ImageIcon( new URL( "http://foo/bar/baz.gif" ) );

Similar Messages

  • How Can I Determine the Size of the 'My Documents' Folder for every user on a local machine using VBScript?

    Hello,
    I am at my wits end into this. Either I am doing it the wrong way or it is not possible.
    Let me explain. I need a vb script for the following scenario:
    1. The script is to run on multiple Windows 7 machines (32-Bit & 64-Bit alike).
    2. These are shared workstation i.e. different users login to these machines from time to time.
    3. The objective of this script is to traverse through each User Profile folder and get the size of the 'My Documents' folder within each User Profile folder. This information is to be written to a
    .CSV file located at C:\Temp directory on the machine.
    4. This script would be pushed to all workstations from SCCM. It would be configured to execute with
    System Rights
    I tried the script detailed at:
    http://blogs.technet.com/b/heyscriptingguy/archive/2005/03/31/how-can-i-determine-the-size-of-the-my-documents-folder.aspx 
    Const MY_DOCUMENTS = &H5&
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(MY_DOCUMENTS)
    Set objFolderItem = objFolder.Self
    strPath = objFolderItem.Path
    Set objFolder = objFSO.GetFolder(strPath)
    Wscript.Echo objFolder.Size
    The Wscript.Echo objFolder.Size command in the script at the above mentioned link returned the value as
    '0' (zero) for the current logged on user. Although the actual size was like 30 MB or so.
    I then tried the script at:
    http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_27869829.html
    This script returns the correct value but only for the current logged-on user.
    Const blnShowErrors = False
    ' Set up filesystem object for usage
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("WScript.Shell")
    ' Display desired folder sizes
    Wscript.Echo "MyDocuments : " & FormatSize(FindFiles(objFSO.GetFolder(objShell.SpecialFolders("MyDocuments"))))
    ' Recursively tally the size of all files under a folder
    ' Protect against folders or files that are not accessible
    Function FindFiles(objFolder)
    On Error Resume Next
    ' List files
    For Each objFile In objFolder.Files
    On Error Resume Next
    If Err.Number <> 0 Then ShowError "FindFiles:01", objFolder.Path
    On Error Resume Next
    FindFiles = FindFiles + objFile.Size
    If Err.Number <> 0 Then ShowError "FindFiles:02", objFile.Path
    Next
    If Err.Number = 0 Then
    ' Recursively drill down into subfolder
    For Each objSubFolder In objFolder.SubFolders
    On Error Resume Next
    If Err.Number <> 0 Then ShowError "FindFiles:04", objFolder.Path
    FindFiles = FindFiles + FindFiles(objSubFolder)
    If Err.Number <> 0 Then ShowError "FindFiles:05", objSubFolder.Path
    Next
    Else
    ShowError "FindFiles:03", objFolder.Path
    End If
    End Function
    ' Function to format a number into typical size scales
    Function FormatSize(iSize)
    aLabel = Array("bytes", "KB", "MB", "GB", "TB")
    For i = 0 to 4
    If iSize > 1024 Then iSize = iSize / 1024 Else Exit For End If
    Next
    FormatSize = Round(iSize, 2) & " " & aLabel(i)
    End Function
    Sub ShowError(strLocation, strMessage)
    If blnShowErrors Then
    WScript.StdErr.WriteLine "==> ERROR at [" & strLocation & "]"
    WScript.StdErr.WriteLine " Number:[" & Err.Number & "], Source:[" & Err.Source & "], Desc:[" & Err.Description & "]"
    WScript.StdErr.WriteLine " " & strMessage
    Err.Clear
    End If
    End Sub
    The only part pending, is to achieve this for the 'My Documents' folder within each User Profile folder.
    Is this possible?
    Please help.

    Here are a bunch of scripts to get folder size under all circumstances.  Take your pick.
    https://gallery.technet.microsoft.com/scriptcenter/site/search?query=get%20folder%20size&f%5B0%5D.Value=get%20folder%20size&f%5B0%5D.Type=SearchText&ac=2
    ¯\_(ツ)_/¯

  • How do I determine the size of an event (cmd I does not show any size for events).

    How do I determine the size of an Event in iPhoto? (Cmd + I does not show size information at the event level).

    If you're running iPhoto 8 (09) select the event and look at the Info pane at the lower left hand corner of the window.  It will give you the number of photos and size:
    for iPhoto 9 (11) open the Event, select all of the photos in it and open the Info drawer at the right by typing Command+i.  The number of photos and size will be at the top of the Info drawer.
    OT

  • How do I determine the size of my iTunes library

    How do I determine the size of my iTunes library?

    In Music view, you will see the song count, size, and total playing time in the Status Bar at the bottom. 
    If the Status Bar is not present, enable it either via View > Show Status Bar, or by holding the CTRL key while you press the / key.

  • Determining the size of an Image

    I am running Pages 5.2 and I have a document with a whole load of images taken from photos. Usually I shrink the original images to keep the document size manageable but I forgot on some but I don't know which. Is there a way I can determine the size of individual images in the document ?

    In Pages v5.2, there does not appear any means to assess the image storage size, but File > Reduce File Size will offer a prompt stating an amount it can reduce the current selected image.
    Another approach is to select the image, and press command+C to put it on the clipboard. Launch Preview, ignore the open dialog, and choose File > New from Clipboard. You now have two choices to assess image size: 1) Use the Inspector (General Info panel) from the toolbar, or 2) Menu > Tools > Adjust Size...

  • How can I set the size of an image in java?

    How can I set the size of an image in java? I have to choose the width and height of image...thanks to everybody...sorry for my english :-)

    Hi 43477
    Can you provide more details, do you want to setsize to display an image on a screen of when saving image etc?
    PS.
    There is a good invention called googlegoogle is good, but sometimes it's better to use more specific search, there is a search field avove on this page :)

  • How do I determine the size of an object on a particular layer?

    Whether it's a rectangle, circle, line, etc. how do I determine what the size of an object is on a particular layer?

    Right click on the rulers and set the scale to pixels in the dialog
    Go to View>new guide and select the position of the guide lines along horizontal and vertial axes
    Window>info brings up the Info Palette. The information in the right lower corner provides a readout of any selection that you make, e.g. with the marquee tool
    View>grid allows one to bring up a non-printable grid which is useful for orientation. The grid can be set up with subdivisions to suit via Edit>preferences>guides and grid
    You can open a duplicate layer at the top of the stack, then using the brush tool create a straight line for visual projection. The layer can be deleted at any time. To create a straight line, click on the begin point, hold down the shift key, and click on the end point
    Hope that one of these options is useful for your purpose. Please post your progress.

  • How do I determine the size of my iPhoto library?

    I am running out of disk space and I assume that it is due to my photos.
    #1 - how do I determine if this is the case?
    #2 - how can I figure out the size of my library so I buy the correct sized external HD?
    #3 - what is the best practice for moving iPhoto to an external HD? Do people move over only "older" photos or just run iPhoto off the external HD completely?
    Thank you so very much!
    Jen

    #2 - how can I figure out the size of my library so I buy the correct sized external HD?
    Go to your Pictures Folder and find the iPhoto Library there. Use the Finder's File -> Get Info command to get the size of the Library. When you purchase an extenral disk, make sure to format it Mac OS Extended (Journaled). Also, allow room to grow.
    #3 - what is the best practice for moving iPhoto to an external HD? Do people move over only "older" photos or just run iPhoto off the external HD completely?
    There isn't a "best practise" there's only what you need to do. IF the Library is on the external, then you can only view it with the external attached. Are you on a Laptop? Desktop? If you're on a desktop it probably doesn't matter. If you're on a Laptop it might.
    Regards
    TD

  • How do I determine the size of my photo library

    I want to know the size of my photo file so that I can determine how much space I need to store them in iCloud (iPhoto version 9.6)  Os Version 10.10.2
    Thanks
    Dan

    Depends on what you mean and... you can't store an iPhoto Library in the Cloud.
    If you use the size determination in the iPhoto Window, that reports the approximate size if you export everything at the 'Current Setting' (which you would not want to do. See below*)
    If you check the size of the package in the Finder (Pictures / iPhoto Library) that reports the disk space used for the combined size of the Masters, Previews, Thumbnails, Caches, Database and metadata files.
    Though, as I say, it's not really an issue as you can't put an iPhoto Library in the Cloud.
    *This User Tip
    https://discussions.apple.com/docs/DOC-4921
    has details of the options in the Export dialogue.

  • How do I determine the size of an object?

    After an object is instantiated, is there anyway to determine its size (in bytes)?

    Why do you want to know? Java handles memory management for you.
    IIRC for Sun JVM 1.4:
    Objects: four bytes for each reference, boolean, byte, short, int, float or character field, eight bytes for each long or double field, plus sixteen bytes header information.
    Arrays: length * (four for reference, int or float; one for boolean or byte; two for short or character; eightfor long or double), plus sixteen bytes header information.
    Pete

  • How do I change the size of an image when exporting from photos?

    In iPhoto I could create jpeg images of various sizes by exporting  a photo and selecting the quality of the image and the size of the file.  How do I do that in Photos?

    In exactly the same way. File -> Export. If all those options are not visible, note the disclosure arrow, indicated below.

  • How do I determine the size of an event queue?

    Hi,
    I'd like to be able to programmatically determine how many events are in queue so that I can change how they are processed based on how far behind the loop is.
    Is there a way to easily do this in labview? 
    I suppose I could create an identical parallel event loop that just counts the events as they come in, and then subtract the ones that get processed by the main event loop, but it seems like there should be an easier way.
    I'm using LV 8.1
    Thanks,
    Greg

    So you are recomending running two event loops, one waiting for the faster events and one waiting for the slower events?
    I wouldn't put it that way.
    Any event that takes 'long' (eg. a significant amount of time), should be processed in a consumer loop.
    So the event arives in the normal event structure, and is than feed to a consumer loop via a queue.
    In the LabVIEW examples there is a framework example called 'Produces/consumer with events' (or something like that).
    If you have a specific type of event generating very fast and you are only interested in the last a notifier might be usefull.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How do you determine the size of a table in mb

    Hi,
    I have a table which holds a number of pdf docs - I need to find out how large the table is in mb
    How do you do it - is there an sql command ?
    Thanks in anticicpation
    SD.

    Many thanks ............
    select sum(bytes)/1024/1024
    from user_segments
    where segment_name in (select segment_name from user_lobs
    where table_name = 'SUPPORTING_DOCUMENT')
    or segment_name = 'SUPPORTING_DOCUMENT'
    This sql does the trick and tallies with some rather manual calcuations I have done in sql sum(doc_size) on the docs table.
    As a newbie please could you explain segments ?
    Thanks in anticpation
    SD.

  • How do I modify the size limitation on images in PSE 12?

      I frequently use panorama tools in Photoshop CS6 & CC and PSE 12 to generate large images (several sunsets/sunrises reach as much as 370 MB or more --- PNG or TIF without layers).  It apears that PSE 12 (and previous) have a limit less than a tenth of that.  I also understand that there is a registry fix which would allow for larger images to be displayed. 
      A) Is that so?
       B)  What is the patch?
       C)  What are the (unintended) consequences?
      I use Win 7 Pro.  One machine is 32 bit; the primary production machine, 64 bit.  Thanks

    Everything you need to know about PSE maximum sizes is in http://helpx.adobe.com/photoshop-elements/kb/maximum-image-size-limits-photoshop.html.
    The registry fix you are thinking of affects the Organizer only. The Editor has an absolute limit of 30,000 x 30,000 pixels. File size itself is not the constraining factor.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • How can i determine the specified VO is updated or not?

    All
    There are several VOs in my AM and the this.getDBTransaction().isDirty() method returns true once any of the vo changed but not commit. How can i figure out the specific vo to see if it is changed. i want to add customization logic for the specific vo in method beforeCommit() in AM.

    Gerry,
    There is no direct way of doing this for a VO.
    For VO Rows, however, you can call getEntities() and loop through the returned entities calling getEntityState() on them.
    John

Maybe you are looking for

  • Open any jpg picture and they all open

    When I open (display) any picture on my desktop, PREVIEW opens all pictures on desktop. How (or where) do I tell PREVIEW to cool it?

  • Montior/display calibration for photography?

    What is the best way to go about calibrating my MacBook display to give me accurate color representation while working with my photographs? When I get them printed, they don't look as good as they do on my screen. All the tutorials for monitor calibr

  • To implement MB_MIGO_BADI.

    Hi Experts, I need to use this badi for the migo transaction enhancement ( getting the tabstrips on header and item level ) . Which would be the approriate method to activate a tabstrip . I also need to add 2 new fields on the item tab ( quantity and

  • Can connect to Airport Express but not to the internet

    Please help My Airport Express shows the solid green light. I am also able to connect to it and use AirTunes on my HiFi. However I cant connect to the internet. If I plug in my laptop to the router directly the internet works fine. So it is not a rou

  • SAP BW and Data Services

    I need some guidance from experts I am loading from data services to SAP BW at both ends jobs is successful but no data in sap bw i am loading in to sap bw infosource as a target. when i run a job from data services it creates infopakage automaticall