1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <imhdr.h>
# IMCOPY -- Copy image(s)
#
# The input images are given by an image template list. The output
# is either a matching list of images or a directory.
# The number of input images may be either one or match the number of output
# images. Image sections are allowed in the input images and are ignored
# in the output images. If the input and output image names are the same
# then the copy is performed to a temporary file which then replaces the
# input image.
procedure t_imcopy()
char imtlist1[SZ_LINE] # Input image list
char imtlist2[SZ_LINE] # Output image list
bool verbose # Print operations?
char image1[SZ_PATHNAME] # Input image name
char image2[SZ_PATHNAME] # Output image name
char dirname1[SZ_PATHNAME] # Directory name
char dirname2[SZ_PATHNAME] # Directory name
int list1, list2, root_len
int imtopen(), imtgetim(), imtlen()
int fnldir(), isdirectory()
bool clgetb()
begin
# Get input and output image template lists.
call clgstr ("input", imtlist1, SZ_LINE)
call clgstr ("output", imtlist2, SZ_LINE)
verbose = clgetb ("verbose")
# Check if the output string is a directory.
if (isdirectory (imtlist2, dirname2, SZ_PATHNAME) > 0) {
list1 = imtopen (imtlist1)
while (imtgetim (list1, image1, SZ_PATHNAME) != EOF) {
# Strip the image section first because fnldir recognizes it
# as part of a directory. Place the input image name
# without a directory or image section in string dirname1.
call get_root (image1, image2, SZ_PATHNAME)
root_len = fnldir (image2, dirname1, SZ_PATHNAME)
call strcpy (image2[root_len + 1], dirname1, SZ_PATHNAME)
call strcpy (dirname2, image2, SZ_PATHNAME)
call strcat (dirname1, image2, SZ_PATHNAME)
call img_imcopy (image1, image2, verbose)
}
call imtclose (list1)
} else {
# Expand the input and output image lists.
list1 = imtopen (imtlist1)
list2 = imtopen (imtlist2)
if (imtlen (list1) != imtlen (list2)) {
call imtclose (list1)
call imtclose (list2)
call error (0, "Number of input and output images not the same")
}
# Do each set of input/output images.
while ((imtgetim (list1, image1, SZ_PATHNAME) != EOF) &&
(imtgetim (list2, image2, SZ_PATHNAME) != EOF)) {
call img_imcopy (image1, image2, verbose)
}
call imtclose (list1)
call imtclose (list2)
}
end
|