Thanks Martin for the hint! Now it's working. As usual, the devil is in the details...
Using the loadHandler, the image (in my case my thumb) is being resized if image is not in the cache. If you refresh the site, the loadHandler won't be executed. That means, resizing the image has to be in two places. 1. inside the loadHandler 2. outside the loadHandler, in case it's reading from cache... Now, I'm thinking if this approach is the appropriate one... maybe I should shrink the images already when saving to the database for performance reason. On Nov 6, 10:50 am, Martin Trummer <[email protected]> wrote: > well and one alternative, that might sometimes be usefull is, > to transfer the imagename and the imagesize to the client > then you already know the dimensions when you create the image > > On Nov 6, 10:49 am, Martin Trummer <[email protected]> wrote: > > > try to use a load handler > > > the getWidth() methods comment says: > > Gets the width of the image. When the image is in the unclipped > > state, > > the width of the image is not known until the image has been loaded > > (i.e. load event has been fired for the image). > > > if you just create the Image object and call getWidth() immediately, > > it cannot know it's width - because the browser has not even loaded it > > yet > > > It might sometimes work, for images, that the browser already has > > in it's cache. > > > I didn't actually try it, but it sounds reasonable. > > > On Nov 5, 1:38 pm, Dariusz <[email protected]> wrote: > > > > I have an image lets say 600x800 pixel. Now I want to resize downit to > > > 60x80 pixel. > > > > If I use setWidth or setPixelSize( width, height ), then it sometimes > > > it does it correctly and sometimes not. I've got this problem in both > > > IE & FF. > > > > Do I need to do it within a loadHandler()? Or does anyone has a > > > better solution for it? > > > > My approach: > > > > Image thumb = new Image( "C:\path\to\image.jpg" ); > > > int w = thumb.getWidth(); > > > int h = thumb.getHeight(); > > > > int newH = 60; > > > int newW = ( w * newH ) / h; > > > if( h > newH ) { > > > thumb.setPixelSize( newW, newH ); > > > > } > > > > Thanks in advance! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
