File: any2xpm

package info (click to toggle)
siag 3.0.6-4
  • links: PTS
  • area: main
  • in suites: slink
  • size: 3,652 kB
  • ctags: 6,202
  • sloc: ansic: 40,351; lisp: 3,435; sh: 143; makefile: 112
file content (59 lines) | stat: -rwxr-xr-x 1,108 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

# Attempt to convert any image file to XPM format. Requires the netpbm
# package for all formats except XPM itself. JPEG also requires the
# djpeg program.

# Compressed files are automatically decompressed before converting.
# Requires gzip and uncompress.

# For unknown extensions, the script falls back to anytopnm which is
# part of netpbm.

# echo "Converting $1" 1>&2

convert_image()
{
	case "$1" in
	*.gz )
		name=`basename $1 .gz`
		tmpfile=/tmp/DeCoDe_${name}
		cp $1 ${tmpfile}.gz
		gzip -df ${tmpfile}.gz
		convert_image $tmpfile
		rm ${tmpfile}
		;;
	*.Z )
		name=`basename $1 .Z`
		tmpfile=/tmp/DeCoDe_${name}
		cp $1 ${tmpfile}.Z
		uncompress -f ${tmpfile}.Z
		convert_image ${tmpfile}
		rm ${tmpfile}
		;;
	*.gif | *.GIF )
		giftopnm $1 | ppmtoxpm
		;;
	*.jpg | *.jpeg | *.JPG | *.JPEG )
		djpeg -colors 128 $1 | ppmtoxpm
		;;
	*.tif | *.tiff | *.TIF | *.TIFF )
		tifftopnm $1 | ppmtoxpm
		;;
	*.png | *.PNG )
		pngtopnm $1 | ppmtoxpm
		;;
	*.bmp | *.BMP )
		bmptoppm $1 | ppmtoxpm
		;;
	*.xpm | *.XPM )
		cat $1
		;;
	* )
		anytopnm $1 | ppmtoxpm
		;;
	esac
}

convert_image $1