Can not save a picture in gif format

I just found that Pictures can’t be saved in GIF format. Which is a bummer because the lossless alternatives (TIFF and PNG) produce much larger files in my tests with images that are fairly “flat”.

I also found this bug report about it: <>

Could someone from RS comment on what the problem is here?

I suspect that it has to do with the licensing rights to this format. If that’s true, then let’s please update the documentation (I can do that) and fix the IsExportFormatSupported function so that it returns FALSE as it should if Save can’t handle this format.

Though, that makes no sense with the licensing, either, does it? Because it can load gifs just fine. Unless the licensing issue is with generating gifs in particular? In any case, it’s bad that the IsExportFormatSupported function says that it works when it doesn’t.

Saving as GIF is not so easy as you need to make a 8bit image. You can do that with our MBS Xojo GIF Plugin.

[quote=31120:@Thomas Tempelmann]I just found that Pictures can’t be saved in GIF format. Which is a bummer because the lossless alternatives (TIFF and PNG) produce much larger files in my tests with images that are fairly “flat”.
GIF files use colour palettes of 256 colours and then 8 bits to represent the index into the palette for each pixel. So where you may have RGB (3x8 bits) or RGBA (4 x 8 bits) in other formats for a single pixel you have just 8 bits in GIF. The tricky part is trying to work out which colours to include in the 256 colour palette. It works well with ‘flat’ images. In most formats ‘runs’ of colours can be replaced by a special marker that says here is the colour and it runs for n-pixels to save space in the file. You can represent more than 256 colours in a GIF file by breaking the image into sections, each with its own palette. I don’t know if the PCX file format is supported in Xojo or with any 3rd party but it should provide for similar sizes to GIF, no multiple palettes though from memory.

I believe that all of the software patents have now expired. (The ‘GIF History’ supports the case for software patents being harmful in some cases, it would have been better PR for Unisys to allow free use as it caused much of the world to move away to something that is in many cases better and dislike Unisys in the process - I doubt it was worth the money in licensing fees and admin).

Or use ImageMagick ( from a shell to convert picture

Or if you are on OSX… use the included built-in SIPS utility (no download required)

    // Save Picture in GIF or TIFF format using SIPS command
    // 1. save image as png file in temp directory
    If temp_file.Exists Then temp_file.Delete
    // 2. use sips to convert from PNG to GIF and move to desired directory
    //pic_stack(current_picture).Save temp_file,150 temp_file,Format
    'temp_file.SaveAsPicture Current_Pictur),150
    s="sips -s format "+sips_format+" "+temp_file.shellpath+" --out "+xfile.shellPath
    sh.Mode = 0
    sh.Execute s
    If InStr(sh.Result,"command not found")>0 Then 
      myMsgBox "SIPS Not Found^The Image Conversion utility 'SIPS'^was not located on this computer.^^This is required for GIF and TIFF file^formats.",16
    End If
    If temp_file.Exists Then temp_file.Delete

Some more information: The Picture I have is actually built from GIF data. It’s downloaded via a httpSocket, so I got the data in the content parameter, created the image from it and then wanted to save it. So, the Picture is as good a valid GIF image as it could be.

I solved this issue by saving the content string directly to a file, if its first 6 bytes match the GIF signature “GIF89a”, so I’m good.

The issue why I brought thisup here is not that it doesn’t work and I needed help but that the Docs do not mention this and that IsExportFormatSupported reports the wrong behavior as well. I wanted to get confirmation for this to update at least the docs, which is the best I can do to help.

You forgot the other gif signature GIF87a

47 49 46 38 37 61 GIF87a
47 49 46 38 39 61 GIF89a