Your Digital Media Has Never Looked So Good

 
davinceo
Topic Author
Posts: 3
Joined: Tue Aug 31, 2010 10:02 am

How to obtain photo dimensions on the Roku box?

Tue Aug 31, 2010 10:12 am

Hi All:

How do I determine/obtain photo dimensions (width and height) right on the Roku box. Assume that photo dimensions are not available from the source where I get the photos. Are there any APIs available on the Roku SDK to read the photo headers to get the width and height info?

Appreciate any pointers.
 
hoffmcs
Posts: 119
Joined: Mon Jun 22, 2009 9:55 am

Re: How to obtain photo dimensions on the Roku box?

Tue Aug 31, 2010 4:49 pm

There is no way to determine this from the SDK. Most photo providers give this information in their APIs.
 
davinceo
Topic Author
Posts: 3
Joined: Tue Aug 31, 2010 10:02 am

Re: How to obtain photo dimensions on the Roku box?

Tue Aug 31, 2010 6:40 pm

hoffmcs wrote:
There is no way to determine this from the SDK. Most photo providers give this information in their APIs.


Thank you for your response.

Looks like if you are pulling photos from a USB for instance, you cannot determine the dimensions.
 
kbenson
Posts: 889
Joined: Fri Apr 09, 2010 9:53 am
Location: Santa Rosa, Ca

Re: How to obtain photo dimensions on the Roku box?

Tue Aug 31, 2010 7:51 pm

Well, you CAN, it's just you have to be dedicated. You can read the image into an roByteArray, parse the jpeg/png headers, and pull the dimensions.

If you are willing to wait a week, we'll be open sourcing something easily modifiable to do this for PNG images. I don't imagine it's much harder for JPEG.
-- GandK Labs
Check out Reversi! in the channel store!
 
hoffmcs
Posts: 119
Joined: Mon Jun 22, 2009 9:55 am

Re: How to obtain photo dimensions on the Roku box?

Tue Aug 31, 2010 7:53 pm

I'm always amazed at the interesting solutions people come up with to figure out these problems.
 
renojim
** Valued Community Member **
Posts: 3490
Joined: Mon Feb 15, 2010 1:35 pm

Re: How to obtain photo dimensions on the Roku box?

Tue Aug 31, 2010 9:30 pm

For jpegs, pass an roByteArray:
Function GetJpegDimensions(jpeg as Object) as Dynamic
    if jpeg[0] <> &HFF or jpeg[1] <> &HD8 then return invalid
    i = 2
    w = 0
    h = 0
    len = jpeg.Count()
    while true
        soi1 = jpeg[i]
        soi2 = jpeg[i+1]
        if soi1 = &HFF and (soi2 = &HC0 or soi2 = &HC2) then
            h = jpeg[i+5]*256 + jpeg[i+6]
            w = jpeg[i+7]*256 + jpeg[i+8]
            exit while
        end if
        cnt = jpeg[i+2]*256 + jpeg[i+3]
        i = i + cnt + 2
        if i >= len then
            print "Could not find jpeg dimensions!!!"
            return invalid
        end if
    end while
    return {w:w,h:h}
End Function

-JT
 
davinceo
Topic Author
Posts: 3
Joined: Tue Aug 31, 2010 10:02 am

Re: How to obtain photo dimensions on the Roku box?

Wed Sep 01, 2010 9:38 am

renojim wrote:
For jpegs, pass an roByteArray:


Thank you very much JT and others for your help.

Truly appreciate it.

Who is online

Users browsing this forum: No registered users and 6 guests