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 7615033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:33:17+00:00 2026-05-31T02:33:17+00:00

I have a GWT application that generates SVG files. I want to embed an

  • 0

I have a GWT application that generates SVG files.

I want to embed an image from some URL into my SVG, but I want it to be resized keeping the correct aspect ratio.

I do this by loading the image using the Image class in GWT, and check the height to width, then do some sums to find the height and width I need it to be in my SVG.

I embed the image into the SVG as follows:

<image href="http://some.image/URL.png" height="100" x="50" width="150" y="50"></image>

The issue that I have is when I do the following:

Image image = new Image(sourceURL);
int width = image.getWidth();
int height = image.getHeight();
....

The first time I do this for a particular URL the value of width or height comes back as 0.
Unfortunately retrying in a loop doesn’t seem to fix the problem, but if I ask my application to generate the SVG again, it works.

Any ideas?

  • 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-31T02:33:19+00:00Added an answer on May 31, 2026 at 2:33 am

    Ok, sorry this is not an answer, but comments are too small to put some code.

    I tried the following and it worked perfectly. So you should probably try to isolate your issue in a smaller piece of code:

        @Override
        public void onModuleLoad() {
    
        final Image image = new Image("https://www.google.com/images/srpr/logo3w.png");
        image.addLoadHandler(new LoadHandler() {
    
            @Override
            public void onLoad(LoadEvent event) {
                Window.alert(image.getWidth() + " " + image.getHeight());
            }
        });
        RootLayoutPanel.get().add(image);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GWT application that I want to release as software-as-a-service (SAAS) on
I have a GWT application that displays some charts rendered by JFreeChart. Every few
I have some GWT application that run on the server. we are subscripting with
I have gwt-project that is comunication to database. Application design mvp pattern and view
I have an AWT applet application that needs to be ported over to GWT.
I have googled some time now trying to find a good sample application that
I have a GWT based web application that I have previously uploaded to Appspot.
I have GWT application and I want to secure it using spring security. I
I want to build a GWT application that doesn't use a database. I thought
I have developed a simple application in GWT. After that, I generate war file

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.