When using display.loadRemoteImage, how can you get the resolution of the resulting image?

I am wanting to be able to scale images to fit the screen and need to know what the scale factor to set. 

To know that I need to know the image size. Since it is a downloaded image, how can I tell the image dimensions?

You could try saving it to disk and then load it with display.newImage().  Once loaded you can access width and height.

Tip: SSK2 comes with a handy utility that does exactly what SGS says:

https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/misc/#getimagesize

Source:

misc.getImageSize = function ( path, basePath ) basePath = basePath or system.ResourceDirectory local tmp = display.newImage( path, basePath, 10000,10000 ) if( not tmp ) then return 0, 0 end local sx = tmp.contentWidth local sy = tmp.contentHeight display.remove(tmp) return sx,sy end

Alternately, if you control the server code, you could simply return the width and height of the image as part of the response.

As it turns out, the resulting image downloaded details are handled by the listener…

local function imagenetworkListener( event )

    if ( event.isError ) then

        print ( “Network error - download failed” )

    else

        event.target.alpha = 0

        transition.to( event.target, { alpha = 1.0 } )

    end

    print("Image height: ",event.target.height) 

    print("Image Width: ",event.target.width) 

    print ( "event.response.fullPath: ", event.response.fullPath )

    print ( "event.response.filename: ", event.response.filename )

    print ( "event.response.baseDirectory: ", event.response.baseDirectory )

}

You could try saving it to disk and then load it with display.newImage().  Once loaded you can access width and height.

Tip: SSK2 comes with a handy utility that does exactly what SGS says:

https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/misc/#getimagesize

Source:

misc.getImageSize = function ( path, basePath ) basePath = basePath or system.ResourceDirectory local tmp = display.newImage( path, basePath, 10000,10000 ) if( not tmp ) then return 0, 0 end local sx = tmp.contentWidth local sy = tmp.contentHeight display.remove(tmp) return sx,sy end

Alternately, if you control the server code, you could simply return the width and height of the image as part of the response.

As it turns out, the resulting image downloaded details are handled by the listener…

local function imagenetworkListener( event )

    if ( event.isError ) then

        print ( “Network error - download failed” )

    else

        event.target.alpha = 0

        transition.to( event.target, { alpha = 1.0 } )

    end

    print("Image height: ",event.target.height) 

    print("Image Width: ",event.target.width) 

    print ( "event.response.fullPath: ", event.response.fullPath )

    print ( "event.response.filename: ", event.response.filename )

    print ( "event.response.baseDirectory: ", event.response.baseDirectory )

}