Resizing Image objects to keep inline with JFrame width?

Hi,
just wondering if you had a GUI with an image in it, how you would code an image object to resize itself to keep its scale relative to the JFrame its in, if that frame was being resized by the GUI user?
Thanks!

Previously I'd say just use getScaledInstance() on the image. Then I read this article: [The Perils of Image.getScaledInstance()|http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html]

Similar Messages

  • Resizing Image and Not Keep Aspect Ratio

    Is there a free program to resize images and not keep the original aspect ratio?
    I need to resize loads of images to 100x100 pixels and have tried Image well and IResize yet they do not seem to have an option to not keep the original aspect ratio.
    Thank you
    20" Intel 2GHz Core Duo imac, 2GB Ram, 250 GB HD    

    Hi, Downsize does not seem all that great according to reviews. Why not see if you can buy PS E' 3 mac -- maybe ebay/amazon (if I remember I only paid about $70 for PS E3) As PS E4 just came out I'm sure someone has PS E3 for sale. You will then have no problems completing your image resizing.
    2 other questions for you..are you using the Mac side of your intel or Windows?
    if your using the Windows side I can let you have PS 6 (PC) ..freegratus.

  • Duplicate Image object in PDF file with low resolution

    Hi all,
    On creating images in bitmap mode using illustrator into eps format and convert the eps file into pdf using acrobat distiller.
    On pdf file its showing two objects in the content panel with one object present in low resolution other one same as its original.
    It will not happen in direct pdf from illustrator
    Please anyone help on this.
    Note: It will not happen in grayscale mode.
    Regards,
    Jaya Krishnan

    Hard to follow what you are experiencing, can you post  screenshots?
    You may want to experimnent with your .eps settings, especially preview & inlcude linked files since you have duplicate images.

  • Resizing images in a div to fit browser width

    i have a page with rollovers in a DIV:
    http://toddheymandirector.com/REEL/index_newlook.html
    i want the the images, "nike the getaway", etc, to resize to fit the browser window width. i tried putting them in a div and adding
    row {
        max-width: 100%;
        height: auto;
        width: auto\9; /* ie8 */
    but it didnt work..
    ideas?
    thanks

    You could try something like the below. Basically it will show a maximum of 4 images per row (25%) so:
    if your image width is 300px, for the browser to view all 4 at 100% their window needs to be 1200px wide
    if their browser window is smaller than 1200px, the images will start to move onto new rows
    if the browser window is bigger than 1200px, it will scale the 4 up to fit the width.
    You can change the width of the images to match your optimal browser window and/or change the percentages to see the effect it has.
    Eg, if you remove the "min-width:25%;" from #gallery ul li it will not scale the images at all. If you change "min-width:25%;" to "width:25%;", it will always show 4 images in a row and scale up or down to fit the window.
    Best thing to do is play around until you're happy. Good luck.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body{
        background-color:#666666;
        margin:0;
        padding:0;
    #container{
        width:100%;
        height:auto;
        margin:0;
        padding:0;
    #title{
        width:100%;
        float:left;
        color:#FFFFFF;
        font-family:Arial, Helvetica, sans-serif;
        font-size:140%;
        line-height:150%;
        margin-bottom:30px;
        text-align:center;
    #gallery{
        width:100%;
        height:auto;
        margin:0;
        padding:0;
        float:left;
    #gallery ul{
        width:100%;
        height:auto;
        margin:0;
        padding:0;
        float:left;
        background-color:#666666;
        list-style-type:none;
    #gallery ul li{
        min-width:25%;
        display:block;
        margin:0;
        padding:0;
        float:left;
        background-color:#666666;
    img{
        display:block;
        border:none;
        margin:0;
        padding:0;
        width:100%;
    </style>
    </head>
    <body>
    <div id="container">
    <div id="title">This is a floating web gallery</div>
    <div id="gallery">
    <ul>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    </ul>
    </div>
    </div>
    </body>
    </html>

  • Resizing drawing objects defies pixel snapping

    This happens mostly with drawing objects, and to a lesser degree with shapes. When resizing drawing objects in Flash CS6 with pixel snapping turned on, one would expect the dimensions of the shape to snap to even pixel numbers. For the most part it does, but too frequently the position and size values begin to drift into fractions of pixels.
    If you create a rectangle as a drawing object, no stroke, it will snap to pixels properly. Drag it around and it always lands on whole pixel values. Now try resizing it using the free transform tool, or even by clicking and dragging the position and size values in the properties panel. Width and height values will mostly stick to whole pixels, but too often it will slip into fractions of pixels, bizarrely offsetting the x and y values as well. If you resize a drawing object and this error occurs, it does not help to try and move it to snap it back onto whole pixels, because it will snap to whatever fraction of a pixel it's currently stuck in, thereby forcing the user to manually edit the object's x and y coordinates.
    This is a problem in my workflow as I'm constantly having to keep an eye on the properties panel and manually editing the numbers when shapes stray into 2.85 pixels or some such when I want it at 3. I find myself frequently just entering the numbers I want, which defeats the purpose of pixel snapping in the first place.

    This happens mostly with drawing objects, and to a lesser degree with shapes. When resizing drawing objects in Flash CS6 with pixel snapping turned on, one would expect the dimensions of the shape to snap to even pixel numbers. For the most part it does, but too frequently the position and size values begin to drift into fractions of pixels.
    If you create a rectangle as a drawing object, no stroke, it will snap to pixels properly. Drag it around and it always lands on whole pixel values. Now try resizing it using the free transform tool, or even by clicking and dragging the position and size values in the properties panel. Width and height values will mostly stick to whole pixels, but too often it will slip into fractions of pixels, bizarrely offsetting the x and y values as well. If you resize a drawing object and this error occurs, it does not help to try and move it to snap it back onto whole pixels, because it will snap to whatever fraction of a pixel it's currently stuck in, thereby forcing the user to manually edit the object's x and y coordinates.
    This is a problem in my workflow as I'm constantly having to keep an eye on the properties panel and manually editing the numbers when shapes stray into 2.85 pixels or some such when I want it at 3. I find myself frequently just entering the numbers I want, which defeats the purpose of pixel snapping in the first place.

  • When I import or drag/drop an image from Finder into Pages, it floats the image instead of keeping it inline with text

    I'm new to Pages and I've searched online for an answer to this question but haven't found anything quite what I need.
    When I import an image from Finder (or drag and drop from Finder) into Pages, the Text Wrap default is "automatic" which seems to be "in front of text." I have to manually click each image and then change it from "Automatic" to "Inline With Text." Is there a way to change the default so it's not "Automatic" but "Inline With Text" to save me these steps for every single image I import?
    (If importing from Media Browser would behave differently, I don't use iPhoto except for Photo Stream so I need to bring them in from where I've saved them in my Finder.)
    Thanks so much for any help!

    Good questions...  I'll have to try and figure out when the problem first happened - I was thinking it was when I upgraded to Safari 5.1.4 but that might not be the case...  I'll try your suggestions to see if any of them eliminate the problem (I have restarted recenlty and that didn't fix it) but I'll try repairing permissions,etc.  Thanks!
    hmmm... Mcbuffy: are you implying that you *don't* get the webloc when dragging an image out of Safari and that this isn't a caused by change to Safari but is a big/conflict in mine?

  • At my wits end: Placing anchored object inline with text & wrap

    Granted I never learned InDesign the way I should.  Once upon a time I fared well with Aldus Pagemaker.  But I've just spent the last two hours trying to resolve a massive gap in my knowledge and I can't do it.  I'm exasperated and desperate for help.
    What I want to do:  I have a tech manual with lots of text and need to place graphic objects in a way that the text will wrap around the object and if I need to edit the text, the graphic will move with where I inserted the graphic.
    What happens:
    1.  I have a text frame with text.  I place the cursor at the beginning of the paragraph and click File> Place, thereafter choosing a graphic.
    2.  Using the selection tool, I click the graphic and then click the icon "wrap around bounding box".
    3.  The text shifts a teeny bit but does not wrap around the object.
    4.  Object is, however, inline/anchored, with text.
    OR
    1.  With nothing selected I click File> Place, thereafter choosing  a graphic.
    2.  I place the graphic on the lower part of the page over a blank space.
    3.  I move the graphic over the text and then click the icon "wrap around bounding box".
    4.  The text flows but when I edit the text, it does not flow around the graphic.
    Conclusion:
    I am retarded.  I even went through Lynda's example here:  http://www.adobe.com/designcenter/video_workshop/?id=vid0073   I was able to place my object in her document and watch the text flow around the text wrapped graphic.
    I read the help docs (I'm a big fan of reading).
    The only thing I can think of is I've set my text box up wrong or I have no idea.  I'm so frustrated I am seriously almost in tears.
    My example document (I'm under an NDA and can't release my original document, but I duplicated what I've done in the previous one) is here for anyone who can tell me what I've done wrong.  Thank you kindly.
    http://www.xandria.ca/test01.indd

    Alrighty, this is bizarre.  I couldn't leave well enough alone and I'm still trying to hammer this one out.  But I just followed my first method described in the original message and then...
    I clicked and dragged the edge of my graphic and the text began to flow around it and it moves with the text.
    What on earth?
    While I can do this for each image, I'd rather not.  What am I still doing wrong, although I seem to have a half baked workaround.
    Cheers.

  • I need some help resizing my images on PS6. I am using a mac and have been trying to resize with same resolution and constaining proportions but for some reaseon the smaller resized image appears pizelated.

    I need some help resizing my images on PS6. I am using a mac and have been trying to resize with same resolution and constaining proportions but for some reaseon the smaller resized image appears pizelated. Heres an image of before and after. The first image I use is a JPG 72dpi 1500px x1500px and I want to downsize it to 600x600px same res, but it keeps pixelating, this has never happened before. Any suggestions, thoughts?
    thanks!

    I wouldn't say pixelated; more like blurry.
    Like ConnectedCreative said, what steps are you using? Are you using "bicubic sharper" when resizing down?

  • Problem with getting resized image's bytes

    I've got a problem with getting correct bytes of a newly resized image. The flow is that I retrive an image from the filesystem. Due to the fact that it is large I resize it to a 50x50px thumbnail. I can display this thumbnail in #benchmark1 (see code below). Unfortunately something's wrong with my imageToBytes funtion which returns reasonably small size of image but is totally useless - I can't make an image of it anymore so at #benchmark2 the application either crashes or keeps freezing. I saved this byte array on my disk and tried to preview under Windows how does it look but I got a message "Preview unavailabe". I did some digging in the Internet and I supposed that it's because I don't use any jpg or png encoders to save the file. Actually I think that it's not the case, as the bytes returned from method imageToBytes look weird - I cannot even make a new image of them and display it without any saving in memory.
                                  byte[] bytes = FileHandler.readFile (
                                          FileHandler.PHOTOS_PATH, fileName);
                                  Image img2 = Image.createImage (bytes, 0, bytes.length);
                                  img2 = ImageHandler.getInstance ().resize (img2);
                                                    //#benchmark1
                                  bytes = ImageUtils.imageToBytes (img2);
                                  img2 = Image.createImage (bytes, 0, bytes.length);
                                                    //#benchmark2my imageToBytes function is as follows:
         public static byte[] imageToBytes (Image img)
              int[] imgRgbData = new int[img.getWidth () * img.getHeight ()];
              byte[] imageData = null;
              try
                   img.getRGB (imgRgbData, 0, img.getWidth (), 0, 0, img.getWidth (),
                           img.getHeight ());
              catch (Exception e)
              ByteArrayOutputStream baos = new ByteArrayOutputStream ();
              DataOutputStream dos = new DataOutputStream (baos);
              try
                   for (int i = 0; i < imgRgbData.length; i++)
                        dos.writeInt (imgRgbData);
                   imageData = baos.toByteArray ();
                   baos.close ();
                   dos.close ();
              catch (Exception e)
              return imageData;
    I've run totally out of any idea what's wrong, please help!
    Edited by: crawlie on Jul 17, 2010 6:21 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hey Crawlie,
    Please note that simply writing int values into ByteArrayOutputStream will not suffice. Please have a look at the following conversion from int pixel value into byte[4]:
    public static final byte[] intToByteArray(int value) {
            return new byte[] {
                    (byte)(value >>> 24),
                    (byte)(value >>> 16),
                    (byte)(value >>> 8),
                    (byte)value
    }Good Luck!
    Daniel

  • Resize an object (image) doesn't work?

    Hi
    I'm trying to resize an image, but nothing happens. I'm following the instructions in the Help page.
    Description:
    - Click the Select Object tool.
    - Selection handles appear when the pointer is over the image (so the image is not locked).
    - Click the image. A thicker selection border appears.
    - Drag a handle of the object.
    - The selection is changing size, but nothing happens with the image.
    Same thing with Shift-drag the handle (to retain the original aspect ratio), nothing happens with the image.
    What is wrong?
    Note:
    the image is also a link. Could it be that the selection that appears is for the link, and not for the image? If so, how can I select the image instead?
    I have tried to remove the image link (Select Object tool, right click the image, Properties, remove link), but the image could still not be resized.
    Software:
    Adobe Acrobat X Standard
    Windows 7 Pro

    I don't think there is an "object touchup tool".
    Adobes help for Adobe Acrobat X Standard says:
    Resize an object
    Click the object with the Select Object tool , or the tool used to create the object.
    Drag a handle of the object. Shift-drag the handle to retain the original aspect ratio.
    Link:
    http://help.adobe.com/en_US/acrobat/standard/using/WS58a04a822e3e50102bd615109794195ff-7c7 4.w.html
    But only the selection border is being resized, not the image.
    I'm beginning to believe there is a bug in the resizing function.

  • Resizing Image when JFrame resized?

    I have a JFrame with a JPanel added to the contentPane (BorderLayout.CENTER). In the JPanel is a JLabel (BorderLayout.CENTER) with an ImageIcon set to it. The image is a subimage of a larger image whose width is scaled to fit the current JLabel width (which is dictated by the JPanel width and finally dictated by the JFrame width).
    When the user resizes the JFrame, the image of the ImageIcon should be replaced with a new image which has been scaled to fit the new width and that reflects the new portion of the larger source image that is visible.
    The JFrame already has a ComponentListener added for retaining the current JFrame size and screen position, but calling my resizeDisplay() method from componentResized() does not seem to have the updated JLabel size. I have added a ComponentListener to the JLabel and called my resizeDisplay() method from componentResized() but it does not seem to have the updated JLabel size either.
    How can my application properly react to JFrame resizes so that the method is retrieving the new size values?
    Thanks,
    Robert Templeton

    Its always easier to solve a problem when sample code (not a complete program) is posted with the question.
    Maybe I don't understand the question, but when I run the following code the output reflects the size of the label after it has been resized. I'm using JDK1.3 on Window 98.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TestLabel extends JFrame
         public TestLabel()
              JPanel panel = new JPanel();
              setContentPane( panel );
              panel.setPreferredSize( new Dimension( 200, 200 ) );
              panel.setLayout(new BorderLayout() );
              final JLabel myLabel = new JLabel( new ImageIcon("dukeWaveRed.gif"), JLabel.CENTER );
              panel.add( myLabel );
              myLabel.addComponentListener( new ComponentAdapter()
                   public void componentResized(ComponentEvent e)
                        System.out.println( myLabel.getSize() );
         public static void main(String[] args)
              TestLabel frame = new TestLabel();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }

  • How do I insert multiple images inline with text in Pages 5.0?

    I have over 20 images in my iPhoto library that I want to insert in a document one after the other (inline with text).
    How do I do this without having to insert them one by one and going into the image options to change the formatting? It's a pain to have to do it this way...
    I tried using the media browser in Pages, but it seems you can only add them one by one. So I exported the pictures from iPhoto into a folder, selected them all in Finder and dragged them onto my document. All the images appeared stacked on top of each other in a random spot on my page. I can't select them all for some reason. So again, I have to click on them one by one to the formatting? Why is this not simpler? Am I missing something?

    If you use the Help in your Pages 5 you will find the followings link http://help.apple.com/pages/mac/5.0/?lang=en#/tanca246d3ac

  • Displaying thumbnail images inline with a report

    Hi,
    I have a table with data and one column which is a text image filename. This image file resides on another server. I currently have a cgi that takes the image filename as a parameter and returns the image be viewed in a browser. I've been able to create a report where the image file name was a hyperlink that opens the image in the browser. I've also been able to create a static html page that can display the image inline with the APEX page, but the html is hardcoded.
    My desire is to have the thumbnail appear inline with the report in its own column. Is this possible? I've seen it in some demos, but the images were stored in the database or the database servers filesystem.

    Yes, it is possible.
    I did just that.
    Here what I did
    SQL> desc dept
    Name Null? Type
    DEPTNO NOT NULL NUMBER(2)
    DNAME VARCHAR2(14)
    LOC VARCHAR2(13)
    PICS VARCHAR2(20)
    PICS hold the file name of the image, I name my thumbnail and the picture with the same name but store in different directories under HTTPHOME/images, name pics and thumbail
    I created an interactive report in APEX
    select
    "DEPTNO",
    "DNAME",
    "LOC",
    '<img src="#IMAGE_PREFIX#thumbnail/'||"PICS"||'" border="0">' AS PIC_LINK
    from "DEPT"
    In the interactive report attribute, I set the "DISPLAY TEXT AS" for PIC_LINK as "Standard Report Column"
    If you are using XDB, you need to re-copy you images(This part I don't like) to database every time you change/add/delete an image.
    If you are using HTTP server, then that it is.
    I am looking for a way to dynamically show the thumbnail with providing an image file in APEX. So,that I don't have to use 2 files
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to resize image with high quality

    I refer lot of examples in image resizing. But quality of resized image not good. pls can give me solution for that with code?

    I refer lot of examples in image resizing.Have you read [_this article_|http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html]?
    db

  • AppleScript to resize images and save with new name

    I want to make an apple script, which resizes all images of a folder regardless what kind of filetype.
    The source folder will change every day.
    With the script i want to choose a source Folder, resize all images and save the files with my jpeg options in the same folder, but with adding  „_ipad“ in the filename.
    I tried to edit an existing script from this forum, but in Photoshop 5.1 i get the error-message "This function is possibly not available in this Version" in line 18 "save in file newFileName as JPEG with options myOptions"
    How can i save the documents with new name in the existing folder?
    Thanks.
    This is the script i’m working with:
    set inputFolder to choose folder with prompt "Wähle einen Ordner:"
    --set destinationFolder to choose folder with prompt "Wähle einen Zielordner" as string
    tell application "Finder"
              set filesList to (files of entire contents of inputFolder) as alias list
    end tell
    tell application "Adobe Photoshop CS5.1"
              set UserPrefs to properties of settings
              set ruler units of settings to pixel units
              repeat with aFile in filesList
      open aFile showing dialogs never
                        set docRef to the current document
                        tell docRef
                                  set newFileName to my getBaseName(name)
      --resize image height 240 resolution 72 resample method bicubic sharper
      change mode to RGB
      resize image resolution 72
                                  set myOptions to {class:JPEG save options, embed color profile:true, quality:12, format options:progressive, scans:3}
      save in file newFileName as JPEG with options myOptions
                        end tell
      close the current document saving no
              end repeat
              set ruler units of settings to ruler units of UserPrefs
    end tell
    on getBaseName(fName)
              set baseName to fName
              repeat with idx from 1 to (length of fName)
                        if (item idx of fName = ".") then
                                  set baseName to (items 1 thru (idx - 1) of fName) as string
                                  exit repeat
                        end if
              end repeat
              return baseName
    end getBaseName

    This seems like a Photoshop error not an AppleScript one. Have you looked in the Photoshop dictionary to see if the command you are getting the error on exists and if it has those options?
    If all you want to do is resize image files and save the resized image file you might want to look at Automator. Specifically the Scale Image action under Photos.
    regards

Maybe you are looking for