Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Anastasiyav
Level 8

Is there any way to get Image size from url?

Jump to solution

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 "

0 Kudos
1 Solution

Accepted Solutions
Anastasiyav
Level 8

Re: Is there any way to get Image size from url?

Jump to solution

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

View solution in original post

0 Kudos
2 REPLIES 2
renojim
Community Streaming Expert

Re: Is there any way to get Image size from url?

Jump to solution

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

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
Anastasiyav
Level 8

Re: Is there any way to get Image size from url?

Jump to solution

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
0 Kudos