5
; PURPOSE: write a image from memory to a GIF
7
; CATEGORY: Images (IO)
10
; WRITE_GIF, filename, image, Red, Green, Blue, $
11
; background_color=background_color, close=close, $
12
; delay_time=delay_time, disposal_method=disposal_method, $
13
; multiple=multiple, repeat_count=repeat_count, $
14
; transparent=transparent, user_input=user_input,
15
; test=test, help=help, debug=debug
18
; Except very basic output, nothing is supported now, please contribute !
20
; OPTIONAL INPUTS: For pseudocolor only
21
; red : the Red colormap vector (for PseudoColor images)
22
; green: the Green colormap vector (for PseudoColor images)
23
; blue : the Blue colormap vector (for PseudoColor images)
26
; Requires ImageMagick (tested)
27
; Most Keywords are not operational now.
30
; Use ImageMagick to write the data as requested
33
; READ_JPEG, 'testsuite/Saturn.jpg', image
34
; WRITE_GIF, 'Saturn2.gif', image
36
; MODIFICATION HISTORY:
37
; Written by: Alain Coulais 2011-11-30
38
; Derived work from WRITE_JPEG by: Christopher Lee 2004-05-17
42
; This program is free software; you can redistribute it and/or modify
43
; it under the terms of the GNU General Public License as published by
44
; the Free Software Foundation; either version 2 of the License, or
45
; (at your option) any later version.
49
pro GIF_MESSAGE, mot_clef
50
MESSAGE, /Continue, 'This Keyword '+STRUPCASE(mot_clef)+' is not operational'
51
MESSAGE, /Continue, 'Please contribute !!'
54
pro WRITE_GIF, filename, image, Red, Green, Blue, $
55
background_color=background_color, close=close, $
56
delay_time=delay_time, disposal_method=disposal_method, $
57
multiple=multiple, repeat_count=repeat_count, $
58
transparent=transparent, user_input=user_input, $
59
test=test, help=help, debug=debug
61
if ~KEYWORD_SET(debug) then ON_ERROR, 2
63
if KEYWORD_SET(help) then begin
64
print, 'pro WRITE_GIF, filename, image, Red, Green, Blue, $'
65
print, ' background_color=background_color, close=close, $'
66
print, ' delay_time=delay_time, disposal_method=disposal_method, $'
67
print, ' multiple=multiple, repeat_count=repeat_count, $'
68
print, ' transparent=transparent, user_input=user_input, $'
69
print, ' help=help, test=test, debug=debug'
73
; Do we have access to ImageMagick functionnalities ??
75
if (MAGICK_EXISTS() EQ 0) then begin
76
MESSAGE, /continue, "GDL was compiled without ImageMagick support."
77
MESSAGE, "You must have ImageMagick support to use this functionaly."
80
if KEYWORD_SET(background_color) then GIF_MESSAGE, 'background_color'
81
if KEYWORD_SET(close) then GIF_MESSAGE, 'close'
82
if KEYWORD_SET(delay_time) then GIF_MESSAGE, 'delay_time'
83
if KEYWORD_SET(disposal_method) then GIF_MESSAGE, 'disposal_method'
84
if KEYWORD_SET(multiple) then GIF_MESSAGE, 'multiple'
85
if KEYWORD_SET(user_input) then GIF_MESSAGE, 'user_input'
86
if KEYWORD_SET(transparent) then GIF_MESSAGE, 'transparent'
87
if KEYWORD_SET( user_input) then GIF_MESSAGE, ' user_input'
89
MESSAGE, /continue, 'This is a very preliminary procedure, please report problems'
90
MESSAGE, /continue, '(if possible with link to the input image/test case)'
92
n=SIZE(image, /n_dimensions)
93
s=SIZE(image, /dimensions)
95
if KEYWORD_SET(test) then STOP
97
if (n LT 2) then begin
98
MESSAGE, 'Image must be 2D or 3D'
101
if (n GT 3) then begin
102
MESSAGE, 'We don''t know how to manage a >3D image, please contribute'
105
if n EQ 2 then mid=MAGICK_CREATE(s[0],s[1])
106
if n EQ 3 then mid=MAGICK_CREATE(s[1],s[2])
110
MAGICK_WRITE, mid, image, rgb=rgb
111
MAGICK_WRITEFILE, mid, filename,"GIF"
114
if KEYWORD_SET(test) then STOP