Forum Discussion

Anastasiyav's avatar
Anastasiyav
Channel Surfer
4 years ago
Solved

Is there any way to get Image size from url?

Is there any way to check the image size?

For example, in some cases I getting images with 1px*1px size. And I need to check it. If it's, I need to use the failedBitmap uri for the image. 

I tried to check using CreateObject("roBitmap", imagePath) and GetWidth()/GetHeight() methods. But it doesn't work with this types of url: "https://imgsServerUrl/api/images?id={id}&t={type}&width=260&height=260 "

  • Found a solution. 

    It has turned out easier than I thought. 

    Need to check the bitmapWidth/bitmapHeight when loadStatus for Poster is "ready".

    Observe loadStatus for Poster and then

    sub LoadStatus_Changed(event as dynamic)
        status = event.GetData()
        if (status = "ready") then
            if (m.top.bitmapWidth <= 1.5 and m.top.failedBitmapUri <> invalid and m.top.failedBitmapUri <> "") then
                m.top.uri = m.top.failedBitmapUri
            end if
        end if
    end sub

2 Replies

  • Found a solution. 

    It has turned out easier than I thought. 

    Need to check the bitmapWidth/bitmapHeight when loadStatus for Poster is "ready".

    Observe loadStatus for Poster and then

    sub LoadStatus_Changed(event as dynamic)
        status = event.GetData()
        if (status = "ready") then
            if (m.top.bitmapWidth <= 1.5 and m.top.failedBitmapUri <> invalid and m.top.failedBitmapUri <> "") then
                m.top.uri = m.top.failedBitmapUri
            end if
        end if
    end sub
  • renojim's avatar
    renojim
    Community Streaming Expert

    You would probably have to download the bitmap to tmp:/ and then get the dimensions.