View Full Version : Retrieve JPG from URL
BeRnA
May 25th, 2005, 10:59 AM
Can someone help me (if is possible) to retrieve an image (JPG) from an URL (http protocol).
Thanks
Promixis
May 25th, 2005, 11:22 AM
from the not yet done weather module
local b,HTTPERROR = self.SatMaphttp.request( self.SatMap.URL )
if HTTPERROR == 200 then -- no error
local f = assert(io.open(self.SatMap.Filename, "wb"))
local t = f:write(b)
f:close()
self.SatMapMutex:lock ()
self.SatMap.LastUpdate = win.GetElapsedSeconds ()
self.SatMapMutex:unlock ()
self:LogUpdate (self.SatMap.Product)
else
self:LogUpdate (self.SatMap.Product,"Error "..(HTTPERROR or "unknown"))
end
BeRnA
May 25th, 2005, 11:54 AM
self.SatMaphttp.request( self.SatMap.URL )
What this object ?
I have this code:
b, HTTPERROR = self.SatMaphttp.request( 'http://myurl' )
if HTTPERROR == 200 then
print ('OK')
else
print('Error')
end
BeRnA
May 25th, 2005, 12:04 PM
Sorry, one more question... I'm trying to convert JPG to BMP as I suspect that the function you implement only receive a BMP file (is'nt correct?)
Now, I found a function win.ConvertImageFormat, what does this function do? and what are the parameters?
Thsnks any help.
Promixis
May 25th, 2005, 12:33 PM
http=require("socket.http")
local b,HTTPERROR = http.request(URL )
if HTTPERROR == 200 then -- no error
local f = assert(io.open(self.SatMap.Filename, "wb"))
local t = f:write(b)
f:close()
end
try this instead.
see the lua windows function example gml on how to use the convert image. the function above will download any type of file.
BeRnA
May 25th, 2005, 12:56 PM
ohhhhhh! Coolllllll! It works very well!!! Thanks a lottt!!!
PS: Now it's only missing the setbackgroud function, I will have to wait :o
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.