Can't load a GIF into a picture?

Hi there,

I’m trying to laod a GIF into a picture:

[code] Dim logoPath as String
Dim data as MemoryBlock
Dim urlSocket As New HTTPSocket
Dim p as picture

// Open Picture from URL
logoPath = “http://www.mywebpage.de/fotos/aaa_logo.gif
data = urlSocket.Get(logoPath, 10)
p = Picture.FromData(data)

Return p[/code]

If I try this with a .JPG it works. If I try it with a .GIF like in the example above, p crashes with NIL.

Does picture support GIF-Format? What can I do to solve the problem?

Thanks in advance!

Frank

Please read the LangRef, it answers this question quite nicely

Thank you Dave. But I don’t want to save a GIF (you’re quoting “SaveAsGif”).

I’m testing on a mac, XOJO WebEdition. And the LangRef says:

I think I will try to display the pictures (JPG, PNG and GIF) in a HTMLViewer, if picture won’t work. Or do you have any other suggestions?

The Web edition has different APIs internally.
it may not support GIF directly.

We do have a GIF plugin available:
http://www.monkeybreadsoftware.net/pluginpart-gif.shtml

Your time out maybe too short. Give it 30 seconds at least.

If you’re using Web edition you could also just send the gif to the browser, no need to download it to your server.

You might have to roll your own custom control with the WebSDK to supply your own <img> tag because the docs say that WebImageView only supports PNG and JPEG.

But really, hotlinking via the image tag would be better for everyone except the image host in the long run. It saves your server from having to download, convert, and serve the image.

The user wins with faster loading.
You win with faster loading, and less server stress.
The original image host loses out however, because hotlinking is essentially stealing their bandwidth.

Thanks to all. Since it is my own webserver I’m referencing pictures to, I’ll give the hotlinking-approach of Tim a try.

It’s working now pretty well for me. If you’re interested in my solution:

I declared a constant constMyPic, holdig the HTML-Code for embedding the picture. The parameter %s will be replaced by the name of the picture in the Sub GetPicture:

[code]Private Const constMyPic as String =

AMC-Forum

[/code]
Public Sub GetPicture(foo as String)
  dim pic as string
  // pic erhlt den HTML-Code zur Darstellung des Bildes
  
  if foo <>"" then
    // Es ist der Dateiname fr ein Foto gespeichert
    if PictureExists(glbPathToFotos + foo) then
      // Das Foto existiert auf dem Server
      pic = Replace(constMyPic, "%s", foo)
    else
      // Bild existiert nicht
      pic = Replace(constMyPic, "%s", "nopic80x100.png")
    end if
    
  else
    // Text ist leer
    pic = Replace(constMyPic, "%s", "nopic80x100.png")
    
  end if
  
  // Jetzt den in pic gespeicherten HTML-Text laden
  htmlPerson.LoadPage(pic)
  
End Sub

In Sub GetPicture() the existence of the picture ist checked in the global function PictureExists():

[code]Public Function PictureExists(cPath as String) as Boolean
// Prft, ob das Bild existiert
// cPath: z. B. glbHostPathToUserPic+“nopic80x100.gif”, also z. B. “upload/bilder/user/nopic80x100.gif”

Dim logoPath as String
Dim logoLocation as FolderItem
Dim result as Boolean = false

#If DebugBuild Then
logoPath = glbHostRootLocal
#else
logoPath = glbHostRootServer
#endif

logoPath = logoPath+cPath
logoLocation=New FolderItem(logoPath, FolderItem.PathTypeShell)

result = logoLocation.Exists

Return result
End Function
[/code]

Perhaps this helps, if someone has the same problem :slight_smile: