#20 Function to set cache file type


The GIF plugin produces excellent quality images but,
as several people have commented in these fora, it is
pretty slow.

It might be possible to speed things up by rewriting
the GIF code, but in the mean time there is a very
simple (if rather ugly) way of nearly doubling the
speed when saving multipage GIFs.

Each image in the multipage GIF is written to a cache
in compressed form when it is appended with
FreeImage_AppendPage. When the multipage GIF is closed
with FreeImage_CloseMultiBitmap, all the cached images
are decompressed and then compressed again into the
multipage file which is saved to disk.

The slowness of the compression routines used for GIF
means that it makes sense to do the cache write (and
read) using a file format other than GIF. Currently,
this is easily done by modifying the Freeimage source
code to set the variable cache_fif in the function
FreeImage_OpenMultiBitmap to the required file type -
for example FIF_TIFF.

To allow the cache file type to be selected from
outside the library, I therefore request that a new
Freeimage function be provided for this purpose.

Alternatively, FreeImage_OpenMultiBitmap could be given
an additional argument cache_fif of type
FREE_IMAGE_FORMAT, and have the line

header->cache_fif = fif;

replaced by

header->cache_fif = cache_fif;

(The default value the value of cache_fif would
obviously be fif).

Because not every choice of cache format will be
compatible with the main format being saved (for
example, a cache format which does not support 8-bit
should not normally be used when saving 8-bit GIF), it
would be a good idea to add warning text to the source
code about this.




Cancel   Add attachments