1 |
;; convert.el |
2 |
;; Created by Laurence D. Finston (LDF). |
3 |
|
4 |
;; $Id: convert.el,v 1.7 2008/01/05 17:59:16 lfinsto1 Exp $ |
5 |
|
6 |
;;;; * (1) Copyright and License. |
7 |
|
8 |
;;;; This file is part of GNU 3DLDF, a package for three-dimensional drawing. |
9 |
;;;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 The Free Software Foundation |
10 |
|
11 |
;;;; GNU 3DLDF is free software; you can redistribute it and/or modify |
12 |
;;;; it under the terms of the GNU General Public License as published by |
13 |
;;;; the Free Software Foundation; either version 3 of the License, or |
14 |
;;;; (at your option) any later version. |
15 |
|
16 |
;;;; GNU 3DLDF is distributed in the hope that it will be useful, |
17 |
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
;;;; GNU General Public License for more details. |
20 |
|
21 |
;;;; You should have received a copy of the GNU General Public License |
22 |
;;;; along with GNU 3DLDF; if not, write to the Free Software |
23 |
;;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
24 |
|
25 |
;;;; GNU 3DLDF is a GNU package. |
26 |
;;;; It is part of the GNU Project of the |
27 |
;;;; Free Software Foundation |
28 |
;;;; and is published under the GNU General Public License. |
29 |
;;;; See the website http://www.gnu.org |
30 |
;;;; for more information. |
31 |
;;;; GNU 3DLDF is available for downloading from |
32 |
;;;; http://www.gnu.org/software/3dldf/LDF.html. |
33 |
|
34 |
;;;; Please send bug reports to Laurence.Finston@gmx.de |
35 |
;;;; The mailing list help-3dldf@gnu.org is available for people to |
36 |
;;;; ask other users for help. |
37 |
;;;; The mailing list info-3dldf@gnu.org is for sending |
38 |
;;;; announcements to users. To subscribe to these mailing lists, send an |
39 |
;;;; email with ``subscribe <email-address>'' as the subject. |
40 |
|
41 |
;;;; The author can be contacted at: |
42 |
|
43 |
;;;; Laurence D. Finston |
44 |
;;;; c/o Free Software Foundation, Inc. |
45 |
;;;; 51 Franklin St, Fifth Floor |
46 |
;;;; Boston, MA 02110-1301 |
47 |
;;;; USA |
48 |
|
49 |
;;;; Laurence.Finston@gmx.de |
50 |
|
51 |
;; * (1) Rename the PNM files. |
52 |
|
53 |
(let ((i 0) (filename-stem "3DLDFmp_") old-filename new-filename |
54 |
(new-filename-stem "stars_1")) |
55 |
(while (< i 10) |
56 |
(setq old-filename (concat filename-stem "." (number-to-string i))) |
57 |
(setq new-filename (concat new-filename-stem ".0" (number-to-string i))) |
58 |
|
59 |
(if (file-exists-p old-filename) |
60 |
(progn |
61 |
(message (concat "Renaming " old-filename " to " new-filename ".")) |
62 |
(sit-for .25) |
63 |
|
64 |
(rename-file old-filename new-filename t) |
65 |
|
66 |
;; (setq command-string (concat "convert -geometry 320x240! " |
67 |
;; new-filename " " new-filename-stem |
68 |
;; "_0" (number-to-string i) ".eps")) |
69 |
|
70 |
;; (message (concat "Calling '" command-string "'.")) |
71 |
;; (sit-for .25) |
72 |
|
73 |
;; (shell-command command-string) |
74 |
|
75 |
) ;; then progn |
76 |
|
77 |
;; else |
78 |
(progn |
79 |
(message (concat old-filename " doesn't exist.")) |
80 |
(sit-for .25) |
81 |
) ;; else progn |
82 |
) ;; if |
83 |
|
84 |
(setq i (1+ i)) |
85 |
|
86 |
|
87 |
|
88 |
);; while |
89 |
|
90 |
(while (<= i 64) |
91 |
(setq old-filename (concat filename-stem "." (number-to-string i))) |
92 |
(setq new-filename (concat new-filename-stem "." (number-to-string i))) |
93 |
|
94 |
(if (file-exists-p old-filename) |
95 |
(progn |
96 |
(message (concat "Renaming " old-filename " to " new-filename ".")) |
97 |
(sit-for .25) |
98 |
(rename-file old-filename new-filename t) |
99 |
|
100 |
;; (setq command-string (concat "convert -geometry 320x240! " |
101 |
;; new-filename " " new-filename-stem |
102 |
;; "_" (number-to-string i) ".eps")) |
103 |
|
104 |
;; (message (concat "Calling '" command-string "'.")) |
105 |
;; (sit-for .25) |
106 |
;; (shell-command command-string) |
107 |
|
108 |
) ;; then progn |
109 |
;; else |
110 |
(progn |
111 |
(message (concat old-filename " doesn't exist.")) |
112 |
(sit-for .25) |
113 |
) ;; else progn |
114 |
) ;; if |
115 |
|
116 |
(setq i (1+ i)) |
117 |
|
118 |
);; while |
119 |
) ;; let |
120 |
|
121 |
|
122 |
|
123 |
;; * (1) Make background on Don Quixote picture transparent. |
124 |
;; Not really necessary. |
125 |
|
126 |
convert -transparent white dq_10.png d_10.png |
127 |
|
128 |
;; * (1) Combine images with Don Quixote. |
129 |
|
130 |
(let ((i 0) (filename-stem "scroll_1") |
131 |
(zeroes "00") |
132 |
old-filename new-filename) |
133 |
|
134 |
(while (< i 47) |
135 |
(if (eq i 10) |
136 |
(setq zeroes "")) |
137 |
(setq old-filename (concat filename-stem "_" zeroes |
138 |
(number-to-string i) ".png")) |
139 |
(setq new-filename (concat filename-stem "_" zeroes |
140 |
(number-to-string i) ".png")) |
141 |
|
142 |
(if (file-exists-p old-filename) |
143 |
(progn |
144 |
|
145 |
(setq command-string (concat "convert -geometry 640x480! " |
146 |
old-filename " " new-filename)) |
147 |
|
148 |
(message (concat "Calling '" command-string "'.")) |
149 |
(sit-for .25) |
150 |
|
151 |
(shell-command command-string) |
152 |
|
153 |
|
154 |
(setq command-string (concat "composite -compose Multiply " |
155 |
new-filename " dq_10.png " |
156 |
new-filename)) |
157 |
|
158 |
|
159 |
(message (concat "Calling '" command-string "'.")) |
160 |
(sit-for .25) |
161 |
|
162 |
(shell-command command-string) |
163 |
|
164 |
|
165 |
) ;; then progn |
166 |
|
167 |
;; else |
168 |
(progn |
169 |
(message (concat old-filename " doesn't exist.")) |
170 |
(sit-for .25) |
171 |
) ;; else progn |
172 |
) ;; if |
173 |
|
174 |
(setq i (1+ i)) |
175 |
|
176 |
);; while |
177 |
|
178 |
(while (<= i 73) |
179 |
(setq old-filename (concat filename-stem "." (number-to-string i))) |
180 |
(setq new-filename (concat filename-stem "_" (number-to-string i) ".png")) |
181 |
|
182 |
|
183 |
(if (file-exists-p old-filename) |
184 |
(progn |
185 |
|
186 |
|
187 |
(setq command-string (concat "convert -geometry 640x480! " |
188 |
old-filename " " new-filename)) |
189 |
|
190 |
(message (concat "Calling '" command-string "'.")) |
191 |
(sit-for .25) |
192 |
|
193 |
(shell-command command-string) |
194 |
|
195 |
|
196 |
(setq command-string (concat "composite -compose Multiply " |
197 |
new-filename " dq_10.png " new-filename)) |
198 |
|
199 |
|
200 |
(message (concat "Calling '" command-string "'.")) |
201 |
(sit-for .25) |
202 |
|
203 |
(shell-command command-string) |
204 |
|
205 |
) ;; then progn |
206 |
;; else |
207 |
(progn |
208 |
(message (concat old-filename " doesn't exist.")) |
209 |
(sit-for .25) |
210 |
) ;; else progn |
211 |
) ;; if |
212 |
|
213 |
(setq i (1+ i)) |
214 |
|
215 |
);; while |
216 |
) ;; let |
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
;; * (1) Convert PNGs to PPMs. |
223 |
|
224 |
|
225 |
;; ** (2) |
226 |
|
227 |
(let ((i 0) (filename-stem "scroll_1_") old-filename new-filename |
228 |
(new-filename-stem "scroll_1_ppm") |
229 |
(zeroes "00") |
230 |
) |
231 |
(while (<= i 595) |
232 |
|
233 |
(if (>= i 100) |
234 |
(setq zeroes "") |
235 |
;; else |
236 |
(if (>= i 10) |
237 |
(setq zeroes "0")) |
238 |
) |
239 |
|
240 |
(setq old-filename (concat filename-stem |
241 |
(number-to-string i) ".png")) |
242 |
(setq new-filename (concat new-filename-stem "." zeroes |
243 |
(number-to-string i))) |
244 |
|
245 |
(if (file-exists-p old-filename) |
246 |
(progn |
247 |
|
248 |
(setq command-string (concat "convert -geometry 640x480! " |
249 |
old-filename " ppm:" new-filename)) |
250 |
|
251 |
(message (concat "Calling '" command-string "'.")) |
252 |
;(sit-for 1) |
253 |
|
254 |
(shell-command command-string) |
255 |
|
256 |
) ;; then progn |
257 |
|
258 |
;; else |
259 |
(progn |
260 |
(message (concat old-filename " doesn't exist.")) |
261 |
(sit-for 1) |
262 |
) ;; else progn |
263 |
) ;; if |
264 |
|
265 |
(setq i (1+ i)) |
266 |
|
267 |
|
268 |
|
269 |
);; while |
270 |
|
271 |
) ;; let |
272 |
|
273 |
;; * (1) Make MPEG file directly. |
274 |
|
275 |
ppmtompeg -no_frame_summary -float_dct encode.Params |
276 |
|
277 |
;; * (1) Make GOPs. |
278 |
|
279 |
ppmtompeg -gop -no_frame_summary -float_dct encode.Params_0 |
280 |
mv stars_1.mpg.gop.0 a.gop |
281 |
ppmtompeg -gop -no_frame_summary -float_dct encode.Params_1 |
282 |
mv stars_1.mpg.gop.0 stars_1.mpg.gop.1 |
283 |
mv a.gop stars_1.mpg.gop.0 |
284 |
|
285 |
;; * (1) Copy GOPs. |
286 |
|
287 |
(progn |
288 |
(setq i 3) |
289 |
(setq filename-stem "stars_1.mpg.gop.") |
290 |
(setq old-filename (concat filename-stem "2")) |
291 |
(setq new-filename (concat filename-stem (number-to-string i))) |
292 |
) ;; progn |
293 |
|
294 |
(let ((filename-stem "stars_1.mpg.gop.") |
295 |
old-filename |
296 |
(i 3) |
297 |
new-filename) |
298 |
|
299 |
(setq old-filename (concat filename-stem "2")) |
300 |
|
301 |
(while (<= i 8) |
302 |
(setq new-filename (concat filename-stem (number-to-string i))) |
303 |
|
304 |
(message (concat "Copying " old-filename " to " new-filename)) |
305 |
(sit-for .25) |
306 |
|
307 |
(copy-file old-filename new-filename t) |
308 |
|
309 |
(setq i (1+ i)) |
310 |
|
311 |
) ;; while |
312 |
|
313 |
) ;; let |
314 |
|
315 |
;; * (1) Combine GOPs. |
316 |
|
317 |
ppmtompeg -combine_gops encode.Params_20 |
318 |
|
319 |
|
320 |
|
321 |
;; Local Variables: |
322 |
;; eval:(outline-minor-mode t) |
323 |
;; outline-regexp:";; [*]+" |
324 |
;; abbrev-mode:t |
325 |
;; eval:(read-abbrev-file abbrev-file-name) |
326 |
;; End: |