Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6251445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:36:59+00:00 2026-05-24T13:36:59+00:00

I use an Image object to load a png image as a thumbnail by

  • 0

I use an Image object to load a png image as a thumbnail by calling its setPixelSize() method to resize the image. I also need to retrieve the original size of the image as integers at some point. How can I get the original sizes (width, height) of the image?

ok i found a workaround: I use a dummy container (SimplePanel) and load the image without scaling save its real dimensions and then remove the container from the parent and discard the new Image object. I don’t know if this a good workaround, but it works. Although i would like to know if there is another way…

problem of the workaround: I have a droplist from which i can select logical folders (which contain images). When i select a new folder, and the new set of images is loaded on display, then i get 0 for width and 0 for height.

private void getTrueSize(String fullUrl) {
        Image trueImage = new Image();
        this.tstCon.add(trueImage);
        trueImage.setUrl(fullUrl);
        this.trueHeight = trueImage.getHeight();
        this.trueWidth = trueImage.getWidth();
        //this.tstCon.remove(trueImage);
        //trueImage = null;
        GWT.log("Image [" + this.imgTitle + "] -> height=" + this.trueHeight + " -> width=" + this.trueWidth);//
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:37:00+00:00Added an answer on May 24, 2026 at 1:37 pm

    Extend the Image class and implement onAttach() method. This method is called when a widget is attached to the browser’s document.

    public class Thumb extends Image {
    
        public Thumb(){
            super();
        }
    
        protected void onAttach(){
            Window.alert(getOffsetHeight()+" "+getOffsetWidth()); //this should give you the original value
            setPixelSize(10,10); // this should be the visible value 
            super.onAttach();
        }
    }
    

    if this doesn’t work, try implementing onLoad() instead of onAttach(), since onLoad() will be called after the image is added to DOM so that it definately should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Javascript Map kit, and it use Image object to load images.
I am trying to use the graphics object to load an image in and
I have a thumbnail image inside a div. I use another image as the
I'm making a class that loads an image and calls its method after loading.
I'm trying to load an image file and use it as a texture for
I want to use an image or icon as a custom cursor in WPF
I tried to use an image file in my HTML template. But when I
Is it possible to use an image captured with the iPhone's camera as a
I'd like to use the image property tag constants defined in GDI+ from .NET.
I am planning to develop an iphone app which makes use of image filters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.