geebs
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2012
09:39 AM
Test if URL image exists
New at brightscript.
using this variable:
myimage = "http://192.168.1.100/images/bigimage.jpg"
i just need a way to test if the file exists or not.
something like
result = doesFileExists(myimage)
result can be boolean true/false, or better if the file exists, result holds the URL, otherwise result is null.
Any help? I'm struggling with the docs and cant find any examples. Thanks.
using this variable:
myimage = "http://192.168.1.100/images/bigimage.jpg"
i just need a way to test if the file exists or not.
something like
result = doesFileExists(myimage)
result can be boolean true/false, or better if the file exists, result holds the URL, otherwise result is null.
Any help? I'm struggling with the docs and cant find any examples. Thanks.
5 REPLIES 5

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2012
11:01 AM
Re: Test if URL image exists
Maybe I'm not understanding what you're trying to do, but can't you just try to download the URL? If it succeeds you'll have the contents, if the file doesn't exist you'll get a 404 error.
--Mark
--Mark
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2012
11:16 AM
Re: Test if URL image exists
yeah, you could have a script on the server to query if the file exists and return a boolean value, or use rourltransfer to check for a 200 (OK) html response, or download the file to tmp:// on the roku.
geebs
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2012
12:19 PM
Re: Test if URL image exists
I got the intended results using rourltransfer to check for a 200 (OK) html response. and that works, however I think a better way would be to download my image to tmp:// and then test if portrait or landscape, setting X Y coords accordingly.
my way is not a pretty hack for deciding if portrait or landscape, but I understand that theres a component that can do it but only to local image files.
Even then I tried but cant find any good examples.
any good examples how to check whether a local image is portrait or landscape?
my way is not a pretty hack for deciding if portrait or landscape, but I understand that theres a component that can do it but only to local image files.
Even then I tried but cant find any good examples.
any good examples how to check whether a local image is portrait or landscape?

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2012
12:41 PM
Re: Test if URL image exists
"geebs" wrote:
any good examples how to check whether a local image is portrait or landscape?
This assumes you're really only interested in knowing which dimension is greater, but...
Function IsLandscape(imagePath As String) As Boolean
bitmap = CreateObject("roBitmap", imagePath)
If bitmap <> invalid Then
Return bitmap.GetWidth() > bitmap.GetHeight()
End If
Return False
End Function
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
geebs
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2012
10:39 AM
Re: Test if URL image exists
TheEndless,
Thanks for the function. I didn't notice GetWidth() & GetHeight() was available. That'll work wonderfully.
Thanks for the function. I didn't notice GetWidth() & GetHeight() was available. That'll work wonderfully.