File ras2tiff-comeback.patch of Package tiff.34105

--- tiff-4.0.8/html/man/Makefile.am	2017-06-20 11:26:09.318595254 +0200
+++ tiff-4.0.8/html/man/Makefile.am	2017-06-20 11:27:10.898595486 +0200
@@ -82,6 +82,7 @@
 	gif2tiff.1.html \
 	pal2rgb.1.html \
 	ppm2tiff.1.html \
+	ras2tiff.1.html \
 	raw2tiff.1.html \
 	tiff2bw.1.html \
 	tiff2pdf.1.html \
--- tiff-4.0.8/html/man/Makefile.am.orig	1970-01-01 01:00:00.000000000 +0100
+++ tiff-4.0.8/html/man/Makefile.am.orig	2017-06-20 11:25:46.290595167 +0200
@@ -0,0 +1,124 @@
+# Tag Image File Format (TIFF) Software
+#
+# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
+#
+# Permission to use, copy, modify, distribute, and sell this software and 
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+# 
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+# 
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+# OF THIS SOFTWARE.
+
+# Process this file with automake to produce Makefile.in.
+
+docdir = $(LIBTIFF_DOCDIR)/html/man
+MANSRCDIR = $(top_srcdir)/man
+HTMLMANDIR = $(top_srcdir)/html/man
+
+GROFF = groff -Thtml -mandoc
+ECHO = echo
+
+indexfile = index.html
+docfiles = \
+	libtiff.3tiff.html \
+	TIFFbuffer.3tiff.html \
+	TIFFClose.3tiff.html \
+	TIFFcodec.3tiff.html \
+	TIFFcolor.3tiff.html \
+	TIFFDataWidth.3tiff.html \
+	TIFFError.3tiff.html \
+	TIFFFieldDataType.3tiff.html \
+	TIFFFieldName.3tiff.html \
+	TIFFFieldPassCount.3tiff.html \
+	TIFFFieldReadCount.3tiff.html \
+	TIFFFieldTag.3tiff.html \
+	TIFFFieldWriteCount.3tiff.html \
+	TIFFFlush.3tiff.html \
+	TIFFGetField.3tiff.html \
+	TIFFmemory.3tiff.html \
+	TIFFOpen.3tiff.html \
+	TIFFPrintDirectory.3tiff.html \
+	TIFFquery.3tiff.html \
+	TIFFReadDirectory.3tiff.html \
+	TIFFReadEncodedStrip.3tiff.html \
+	TIFFReadEncodedTile.3tiff.html \
+	TIFFReadRawStrip.3tiff.html \
+	TIFFReadRawTile.3tiff.html \
+	TIFFReadRGBAImage.3tiff.html \
+	TIFFReadRGBAStrip.3tiff.html \
+	TIFFReadRGBATile.3tiff.html \
+	TIFFReadScanline.3tiff.html \
+	TIFFReadTile.3tiff.html \
+	TIFFRGBAImage.3tiff.html \
+	TIFFSetDirectory.3tiff.html \
+	TIFFSetField.3tiff.html \
+	TIFFsize.3tiff.html \
+	TIFFstrip.3tiff.html \
+	TIFFswab.3tiff.html \
+	TIFFtile.3tiff.html \
+	TIFFWarning.3tiff.html \
+	TIFFWriteDirectory.3tiff.html \
+	TIFFWriteEncodedStrip.3tiff.html \
+	TIFFWriteEncodedTile.3tiff.html \
+	TIFFWriteRawStrip.3tiff.html \
+	TIFFWriteRawTile.3tiff.html \
+	TIFFWriteScanline.3tiff.html \
+	TIFFWriteTile.3tiff.html \
+	bmp2tiff.1.html \
+	fax2ps.1.html \
+	fax2tiff.1.html \
+	gif2tiff.1.html \
+	pal2rgb.1.html \
+	ppm2tiff.1.html \
+	raw2tiff.1.html \
+	tiff2bw.1.html \
+	tiff2pdf.1.html \
+	tiff2ps.1.html \
+	tiff2rgba.1.html \
+	tiffcmp.1.html \
+	tiffcp.1.html \
+	tiffcrop.1.html \
+	tiffdither.1.html \
+	tiffdump.1.html \
+	tiffgt.1.html \
+	tiffinfo.1.html \
+	tiffmedian.1.html \
+	tiffset.1.html \
+	tiffsplit.1.html
+
+dist_doc_DATA = $(indexfile) $(docfiles)
+
+INDEXSTART = '<HTML><HEAD><TITLE>Libtiff HTML manpage index</TITLE></HEAD><BODY BGCOLOR=white><ul><H2>Man Pages</h2><p>'
+INDEXEND = '</ul></BODY></HTML>'
+
+.PHONY: index
+index:
+	${ECHO} ${INDEXSTART} > $(indexfile)
+	for i in $(docfiles); do					\
+		${ECHO} '<li><A HREF='$$i'>'$$i'</a>' >> $(indexfile);  \
+	done
+	${ECHO} ${INDEXEND} >> $(indexfile)
+
+manpages = $(docfiles:.html=)
+
+.PHONY: htmldoc
+htmldoc:
+	for i in $(manpages); do					\
+		${GROFF} $(MANSRCDIR)/$$i > $(HTMLMANDIR)/$$i.html;	\
+	done
+
+EXTRA_DIST = \
+	CMakeLists.txt \
+	HtmlDoc.cmake
--- tiff-4.0.8/html/man/ras2tiff.1.html	1970-01-01 01:00:00.000000000 +0100
+++ tiff-4.0.8/html/man/ras2tiff.1.html	2017-06-20 11:27:10.898595486 +0200
@@ -0,0 +1,139 @@
+<!-- Creator     : groff version 1.18.1 -->
+<!-- CreationDate: Sat Feb 24 18:37:19 2007 -->
+<html>
+<head>
+<meta name="generator" content="groff -Thtml, see www.gnu.org">
+<meta name="Content-Style" content="text/css">
+<title>RAS2TIFF</title>
+</head>
+<body>
+
+<h1 align=center>RAS2TIFF</h1>
+<a href="#NAME">NAME</a><br>
+<a href="#SYNOPSIS">SYNOPSIS</a><br>
+<a href="#DESCRIPTION">DESCRIPTION</a><br>
+<a href="#OPTIONS">OPTIONS</a><br>
+<a href="#BUGS">BUGS</a><br>
+<a href="#SEE ALSO">SEE ALSO</a><br>
+
+<hr>
+<a name="NAME"></a>
+<h2>NAME</h2>
+<!-- INDENTATION -->
+<table width="100%" border=0 rules="none" frame="void"
+       cols="2" cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="8%"></td>
+<td width="91%">
+<p>ras2tiff &minus; create a <small>TIFF</small> file from a
+Sun rasterfile</p>
+</td>
+</table>
+<a name="SYNOPSIS"></a>
+<h2>SYNOPSIS</h2>
+<!-- INDENTATION -->
+<table width="100%" border=0 rules="none" frame="void"
+       cols="2" cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="8%"></td>
+<td width="91%">
+<p><b>ras2tiff</b> [ <i>options</i> ] <i>input.ras
+output.tif</i></p>
+</td>
+</table>
+<a name="DESCRIPTION"></a>
+<h2>DESCRIPTION</h2>
+<!-- INDENTATION -->
+<table width="100%" border=0 rules="none" frame="void"
+       cols="2" cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="8%"></td>
+<td width="91%">
+<p><i>ras2tiff</i> converts a file in the Sun rasterfile
+format to <small>TIFF.</small> By default, the
+<small>TIFF</small> image is created with data samples
+packed (<i>PlanarConfiguration</i>=1), compressed with the
+Lempel-Ziv &amp; Welch algorithm (<i>Compression</i>=5), and
+with each strip no more than 8 kilobytes. These
+characteristics can overridden, or explicitly specified with
+the options described below.</p>
+<!-- INDENTATION -->
+<p>Any colormap information in the rasterfile is carried
+over to the <small>TIFF</small> file by including a
+<i>Colormap</i> tag in the output file. If the rasterfile
+has a colormap, the <i>PhotometricInterpretation</i> tag is
+set to 3 (palette); otherwise it is set to 2 (RGB) if the
+depth is 24 or 1 (min-is-black) if the depth is not 24.</p>
+</td>
+</table>
+<a name="OPTIONS"></a>
+<h2>OPTIONS</h2>
+<!-- TABS -->
+<table width="100%" border=0 rules="none" frame="void"
+       cols="5" cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="10%"></td>
+<td width="2%">
+
+<p><b>&minus;c</b></p>
+</td>
+<td width="6%"></td>
+<td width="80%">
+
+<p>Specify a compression scheme to use when writing image
+data: <b>&minus;c none</b> for no compression, <b>&minus;c
+packbits</b> for the PackBits compression algorithm,
+<b>&minus;c jpeg</b> for the baseline JPEG compression
+algorithm, <b>&minus;c zip</b> for the Deflate compression
+algorithm, and <b>&minus;c lzw</b> for Lempel-Ziv &amp;
+Welch (the default).</p>
+</td>
+<td width="0%">
+</td>
+<tr valign="top" align="left">
+<td width="10%"></td>
+<td width="2%">
+
+<p><b>&minus;r</b></p>
+</td>
+<td width="6%"></td>
+<td width="80%">
+
+<p>Write data with a specified number of rows per strip; by
+default the number of rows/strip is selected so that each
+strip is approximately 8 kilobytes.</p>
+</td>
+<td width="0%">
+</td>
+</table>
+<a name="BUGS"></a>
+<h2>BUGS</h2>
+<!-- INDENTATION -->
+<table width="100%" border=0 rules="none" frame="void"
+       cols="2" cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="8%"></td>
+<td width="91%">
+<p>Does not handle all possible rasterfiles. In particular,
+<i>ras2tiff</i> does not handle run-length encoded
+images.</p>
+</td>
+</table>
+<a name="SEE ALSO"></a>
+<h2>SEE ALSO</h2>
+<!-- INDENTATION -->
+<table width="100%" border=0 rules="none" frame="void"
+       cols="2" cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="8%"></td>
+<td width="91%">
+<p><b>pal2rgb</b>(1), <b>tiffinfo</b>(1), <b>tiffcp</b>(1),
+<b>tiffmedian</b>(1), <b>libtiff</b>(3)</p>
+<!-- INDENTATION -->
+<p>Libtiff library home page:
+<b>http://www.remotesensing.org/libtiff/</b></p>
+</td>
+</table>
+<hr>
+</body>
+</html>
--- tiff-4.0.8/man/Makefile.am	2017-06-20 11:26:09.302595253 +0200
+++ tiff-4.0.8/man/Makefile.am	2017-06-20 11:27:10.898595486 +0200
@@ -30,6 +30,7 @@
 	gif2tiff.1 \
 	pal2rgb.1 \
 	ppm2tiff.1 \
+	ras2tiff.1 \
 	raw2tiff.1 \
 	tiff2bw.1 \
 	tiff2pdf.1 \
--- tiff-4.0.8/man/Makefile.am.orig	1970-01-01 01:00:00.000000000 +0100
+++ tiff-4.0.8/man/Makefile.am.orig	2017-06-20 11:25:46.290595167 +0200
@@ -0,0 +1,96 @@
+# Tag Image File Format (TIFF) Software
+#
+# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
+#
+# Permission to use, copy, modify, distribute, and sell this software and 
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+# 
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+# 
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+# OF THIS SOFTWARE.
+
+# Process this file with automake to produce Makefile.in.
+
+dist_man1_MANS = \
+	bmp2tiff.1 \
+	fax2ps.1 \
+	fax2tiff.1 \
+	gif2tiff.1 \
+	pal2rgb.1 \
+	ppm2tiff.1 \
+	raw2tiff.1 \
+	tiff2bw.1 \
+	tiff2pdf.1 \
+	tiff2ps.1 \
+	tiff2rgba.1 \
+	tiffcmp.1 \
+	tiffcp.1 \
+	tiffcrop.1 \
+	tiffdither.1 \
+	tiffdump.1 \
+	tiffgt.1 \
+	tiffinfo.1 \
+	tiffmedian.1 \
+	tiffset.1 \
+	tiffsplit.1
+
+dist_man3_MANS = \
+	libtiff.3tiff \
+	TIFFbuffer.3tiff \
+	TIFFClose.3tiff \
+	TIFFcodec.3tiff \
+	TIFFcolor.3tiff \
+	TIFFDataWidth.3tiff \
+	TIFFError.3tiff \
+	TIFFFieldDataType.3tiff \
+	TIFFFieldName.3tiff \
+	TIFFFieldPassCount.3tiff \
+	TIFFFieldReadCount.3tiff \
+	TIFFFieldTag.3tiff \
+	TIFFFieldWriteCount.3tiff \
+	TIFFFlush.3tiff \
+	TIFFGetField.3tiff \
+	TIFFmemory.3tiff \
+	TIFFOpen.3tiff \
+	TIFFPrintDirectory.3tiff \
+	TIFFquery.3tiff \
+	TIFFReadDirectory.3tiff \
+	TIFFReadEncodedStrip.3tiff \
+	TIFFReadEncodedTile.3tiff \
+	TIFFReadRawStrip.3tiff \
+	TIFFReadRawTile.3tiff \
+	TIFFReadRGBAImage.3tiff \
+	TIFFReadRGBAStrip.3tiff \
+	TIFFReadRGBATile.3tiff \
+	TIFFReadScanline.3tiff \
+	TIFFReadTile.3tiff \
+	TIFFRGBAImage.3tiff \
+	TIFFSetDirectory.3tiff \
+	TIFFSetField.3tiff \
+	TIFFsize.3tiff \
+	TIFFstrip.3tiff \
+	TIFFswab.3tiff \
+	TIFFtile.3tiff \
+	TIFFWarning.3tiff \
+	TIFFWriteDirectory.3tiff \
+	TIFFWriteEncodedStrip.3tiff \
+	TIFFWriteEncodedTile.3tiff \
+	TIFFWriteRawStrip.3tiff \
+	TIFFWriteRawTile.3tiff \
+	TIFFWriteScanline.3tiff \
+	TIFFWriteTile.3tiff
+
+EXTRA_DIST = \
+	CMakeLists.txt
--- tiff-4.0.8/man/ras2tiff.1	1970-01-01 01:00:00.000000000 +0100
+++ tiff-4.0.8/man/ras2tiff.1	2017-06-20 11:27:10.898595486 +0200
@@ -0,0 +1,96 @@
+.\" $Id: ras2tiff.1,v 1.1 2016-06-05 19:53:59 bfriesen Exp $
+.\"
+.\" Copyright (c) 1990-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 Silicon Graphics, Inc.
+.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and 
+.\" its documentation for any purpose is hereby granted without fee, provided
+.\" that (i) the above copyright notices and this permission notice appear in
+.\" all copies of the software and related documentation, and (ii) the names of
+.\" Sam Leffler and Silicon Graphics may not be used in any advertising or
+.\" publicity relating to the software without the specific, prior written
+.\" permission of Sam Leffler and Silicon Graphics.
+.\" 
+.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
+.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+.\" 
+.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+.\" OF THIS SOFTWARE.
+.\"
+.if n .po 0
+.TH RAS2TIFF 1 "November 2, 2005" "libtiff"
+.SH NAME
+ras2tiff \- create a
+.SM TIFF
+file from a Sun rasterfile
+.SH SYNOPSIS
+.B ras2tiff
+[
+.I options
+]
+.I input.ras
+.I output.tif
+.SH DESCRIPTION
+.I ras2tiff
+converts a file in the Sun rasterfile format to
+.SM TIFF.
+By default, the
+.SM TIFF
+image is created with data samples packed (\c
+.IR PlanarConfiguration =1),
+compressed with the Lempel-Ziv & Welch algorithm (\c
+.IR Compression =5),
+and with each strip no more than 8 kilobytes.
+These characteristics can overridden, or explicitly specified
+with the options described below.
+.PP
+Any colormap information in the rasterfile is carried over to the
+.SM TIFF
+file by including a
+.I Colormap
+tag in the output file.
+If the rasterfile has a colormap, the
+.I PhotometricInterpretation
+tag is set to 3 (palette);
+otherwise it is set to 2 (RGB) if the depth
+is 24 or 1 (min-is-black) if the depth is not 24.
+.SH OPTIONS
+.TP
+.B \-c
+Specify a compression scheme to use when writing image data:
+.B "\-c none"
+for no compression,
+.B "\-c packbits"
+for the PackBits compression algorithm,
+.B "\-c jpeg"
+for the baseline JPEG compression algorithm,
+.B "\-c zip
+for the Deflate compression algorithm,
+and
+.B "\-c lzw"
+for Lempel-Ziv & Welch (the default).
+.TP
+.B \-r
+Write data with a specified number of rows per strip;
+by default the number of rows/strip is selected so that each strip
+is approximately 8 kilobytes.
+.SH BUGS
+Does not handle all possible rasterfiles.
+In particular, 
+.I ras2tiff
+does not handle run-length encoded images.
+.SH "SEE ALSO"
+.BR pal2rgb (1),
+.BR tiffinfo (1),
+.BR tiffcp (1),
+.BR tiffmedian (1),
+.BR libtiff (3)
+.PP
+Libtiff library home page:
+.BR http://www.remotesensing.org/libtiff/
+
--- tiff-4.0.8/tools/Makefile.am	2017-06-20 11:26:48.578595402 +0200
+++ tiff-4.0.8/tools/Makefile.am	2017-06-20 11:27:10.898595486 +0200
@@ -37,6 +37,7 @@
 	gif2tiff \
 	pal2rgb \
 	ppm2tiff \
+	ras2tiff \
 	raw2tiff \
 	tiff2bw \
 	tiff2pdf \
@@ -79,6 +80,9 @@
 ppm2tiff_SOURCES = ppm2tiff.c
 ppm2tiff_LDADD = $(LIBTIFF) $(LIBPORT)
 
+ras2tiff_SOURCES = ras2tiff.c rasterfile.h
+ras2tiff_LDADD = $(LIBTIFF) $(LIBPORT)
+
 raw2tiff_SOURCES = raw2tiff.c
 raw2tiff_LDADD = $(LIBTIFF) $(LIBPORT)
 
--- tiff-4.0.8/tools/ras2tiff.c	1970-01-01 01:00:00.000000000 +0100
+++ tiff-4.0.8/tools/ras2tiff.c	2017-06-20 11:27:10.902595486 +0200
@@ -0,0 +1,338 @@
+/* $Id: ras2tiff.c,v 1.1 2016-06-05 19:54:00 bfriesen Exp $ */
+
+/*
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and 
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+ * 
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * OF THIS SOFTWARE.
+ */
+
+#include "tif_config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifdef NEED_LIBPORT
+# include "libport.h"
+#endif
+
+#include "rasterfile.h"
+#include "tiffio.h"
+
+#ifndef howmany
+#define	howmany(x, y)	(((x)+((y)-1))/(y))
+#endif
+#define	streq(a,b)	(strcmp(a,b) == 0)
+#define	strneq(a,b,n)	(strncmp(a,b,n) == 0)
+
+static	uint16 compression = (uint16) -1;
+static	int jpegcolormode = JPEGCOLORMODE_RGB;
+static	int quality = 75;		/* JPEG quality */
+static	uint16 predictor = 0;
+
+static void usage(void);
+static	int processCompressOptions(char*);
+
+int
+main(int argc, char* argv[])
+{
+	unsigned char* buf;
+	long row;
+	tsize_t linebytes, scanline;
+	TIFF *out;
+	FILE *in;
+	struct rasterfile h;
+	uint16 photometric;
+	uint16 config = PLANARCONFIG_CONTIG;
+	uint32 rowsperstrip = (uint32) -1;
+	int c;
+#if !HAVE_DECL_OPTARG
+	extern int optind;
+	extern char* optarg;
+#endif
+
+	while ((c = getopt(argc, argv, "c:r:h")) != -1)
+		switch (c) {
+		case 'c':		/* compression scheme */
+			if (!processCompressOptions(optarg))
+				usage();
+			break;
+		case 'r':		/* rows/strip */
+			rowsperstrip = atoi(optarg);
+			break;
+		case 'h':
+			usage();
+			/*NOTREACHED*/
+		}
+	if (argc - optind != 2)
+		usage();
+	in = fopen(argv[optind], "rb");
+	if (in == NULL) {
+		fprintf(stderr, "%s: Can not open.\n", argv[optind]);
+		return (-1);
+	}
+	if (fread(&h, sizeof (h), 1, in) != 1) {
+		fprintf(stderr, "%s: Can not read header.\n", argv[optind]);
+		fclose(in);
+		return (-2);
+	}
+	if (strcmp(h.ras_magic, RAS_MAGIC) == 0) {
+#ifndef WORDS_BIGENDIAN
+			TIFFSwabLong((uint32 *)&h.ras_width);
+			TIFFSwabLong((uint32 *)&h.ras_height);
+			TIFFSwabLong((uint32 *)&h.ras_depth);
+			TIFFSwabLong((uint32 *)&h.ras_length);
+			TIFFSwabLong((uint32 *)&h.ras_type);
+			TIFFSwabLong((uint32 *)&h.ras_maptype);
+			TIFFSwabLong((uint32 *)&h.ras_maplength);
+#endif
+	} else if (strcmp(h.ras_magic, RAS_MAGIC_INV) == 0) {
+#ifdef WORDS_BIGENDIAN
+			TIFFSwabLong((uint32 *)&h.ras_width);
+			TIFFSwabLong((uint32 *)&h.ras_height);
+			TIFFSwabLong((uint32 *)&h.ras_depth);
+			TIFFSwabLong((uint32 *)&h.ras_length);
+			TIFFSwabLong((uint32 *)&h.ras_type);
+			TIFFSwabLong((uint32 *)&h.ras_maptype);
+			TIFFSwabLong((uint32 *)&h.ras_maplength);
+#endif
+	} else {
+		fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]);
+		fclose(in);
+		return (-3);
+	}
+        if ((h.ras_width <= 0) || (h.ras_width >= INT_MAX) ||
+            (h.ras_height <= 0) || (h.ras_height >= INT_MAX) ||
+            (h.ras_depth <= 0) || (h.ras_depth >= INT_MAX) ||
+            (h.ras_length <= 0) || (h.ras_length >= INT_MAX) ||
+            (h.ras_type <= 0) ||
+            (h.ras_maptype <= 0) ||
+            (h.ras_maplength <= 0) || (h.ras_maplength >= INT_MAX)) {
+                fprintf(stderr, "%s: Improper image header.\n", argv[optind]);
+                fclose(in);
+		return (-2);
+        }
+        if ((h.ras_depth != 1) &&
+            (h.ras_depth != 8) &&
+            (h.ras_depth != 24)) {
+                fprintf(stderr, "%s: Improper image depth (%d).\n",
+                        argv[optind], h.ras_depth);
+                fclose(in);
+		return (-2);
+        }
+	out = TIFFOpen(argv[optind+1], "w");
+	if (out == NULL)
+	{
+		fclose(in);
+		return (-4);
+	}
+	TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) h.ras_width);
+	TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) h.ras_height);
+	TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
+	TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, h.ras_depth > 8 ? 3 : 1);
+	TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, h.ras_depth > 1 ? 8 : 1);
+	TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
+	if (h.ras_maptype != RMT_NONE) {
+		uint16* red;
+		register uint16* map;
+		register int i, j;
+		int mapsize;
+
+		buf = (unsigned char *)_TIFFmalloc(h.ras_maplength);
+		if (buf == NULL) {
+			fprintf(stderr, "No space to read in colormap.\n");
+			return (-5);
+		}
+		if (fread(buf, h.ras_maplength, 1, in) != 1) {
+			fprintf(stderr, "%s: Read error on colormap.\n",
+			    argv[optind]);
+			return (-6);
+		}
+		mapsize = 1<<h.ras_depth; 
+		if (h.ras_maplength > mapsize*3) {
+			fprintf(stderr,
+			    "%s: Huh, %d colormap entries, should be %d?\n",
+			    argv[optind], h.ras_maplength, mapsize*3);
+			return (-7);
+		}
+		red = (uint16*)_TIFFmalloc(mapsize * 3 * sizeof (uint16));
+		if (red == NULL) {
+			fprintf(stderr, "No space for colormap.\n");
+			return (-8);
+		}
+		map = red;
+		for (j = 0; j < 3; j++) {
+#define	SCALE(x)	(((x)*((1L<<16)-1))/255)
+			for (i = h.ras_maplength/3; i-- > 0;)
+				*map++ = SCALE(*buf++);
+			if ((i = h.ras_maplength/3) < mapsize) {
+				i = mapsize - i;
+				_TIFFmemset(map, 0, i*sizeof (uint16));
+				map += i;
+			}
+		}
+		TIFFSetField(out, TIFFTAG_COLORMAP,
+		     red, red + mapsize, red + 2*mapsize);
+		photometric = PHOTOMETRIC_PALETTE;
+		if (compression == (uint16) -1)
+			compression = COMPRESSION_PACKBITS;
+		TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
+	} else {
+		/* XXX this is bogus... */
+		photometric = h.ras_depth == 24 ?
+		    PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK;
+		if (compression == (uint16) -1)
+			compression = COMPRESSION_LZW;
+		TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
+	}
+	switch (compression) {
+	case COMPRESSION_JPEG:
+		if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB)
+			photometric = PHOTOMETRIC_YCBCR;
+		TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
+		TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
+		break;
+	case COMPRESSION_LZW:
+	case COMPRESSION_DEFLATE:
+		if (predictor != 0)
+			TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
+		break;
+	}
+	TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
+	linebytes = ((h.ras_depth*h.ras_width+15) >> 3) &~ 1;
+	scanline = TIFFScanlineSize(out);
+	if (scanline > linebytes) {
+		buf = (unsigned char *)_TIFFmalloc(scanline);
+		_TIFFmemset(buf+linebytes, 0, scanline-linebytes);
+	} else
+		buf = (unsigned char *)_TIFFmalloc(linebytes);
+	TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
+	    TIFFDefaultStripSize(out, rowsperstrip));
+	for (row = 0; row < h.ras_height; row++) {
+		if (fread(buf, linebytes, 1, in) != 1) {
+			fprintf(stderr, "%s: scanline %ld: Read error.\n",
+			    argv[optind], row);
+			break;
+		}
+		if (h.ras_type == RT_STANDARD && h.ras_depth == 24) {
+			tsize_t cc = h.ras_width;
+			unsigned char* cp = buf;
+#define	SWAP(a,b)	{ unsigned char t = (a); (a) = (b); (b) = t; }
+			do {
+				SWAP(cp[0], cp[2]);
+				cp += 3;
+			} while (--cc);
+		}
+		if (TIFFWriteScanline(out, buf, row, 0) < 0)
+			break;
+	}
+	(void) TIFFClose(out);
+	fclose(in);
+	return (0);
+}
+
+static int
+processCompressOptions(char* opt)
+{
+	if (streq(opt, "none"))
+		compression = COMPRESSION_NONE;
+	else if (streq(opt, "packbits"))
+		compression = COMPRESSION_PACKBITS;
+	else if (strneq(opt, "jpeg", 4)) {
+		char* cp = strchr(opt, ':');
+
+                compression = COMPRESSION_JPEG;
+                while( cp )
+                {
+                    if (isdigit((int)cp[1]))
+			quality = atoi(cp+1);
+                    else if (cp[1] == 'r' )
+			jpegcolormode = JPEGCOLORMODE_RAW;
+                    else
+                        usage();
+
+                    cp = strchr(cp+1,':');
+                }
+	} else if (strneq(opt, "lzw", 3)) {
+		char* cp = strchr(opt, ':');
+		if (cp)
+			predictor = atoi(cp+1);
+		compression = COMPRESSION_LZW;
+	} else if (strneq(opt, "zip", 3)) {
+		char* cp = strchr(opt, ':');
+		if (cp)
+			predictor = atoi(cp+1);
+		compression = COMPRESSION_DEFLATE;
+	} else
+		return (0);
+	return (1);
+}
+
+char* stuff[] = {
+"usage: ras2tiff [options] input.ras output.tif",
+"where options are:",
+" -r #		make each strip have no more than # rows",
+"",
+" -c lzw[:opts]	compress output with Lempel-Ziv & Welch encoding",
+" -c zip[:opts]	compress output with deflate encoding",
+" -c jpeg[:opts]	compress output with JPEG encoding",
+" -c packbits	compress output with packbits encoding",
+" -c none	use no compression algorithm on output",
+"",
+"JPEG options:",
+" #		set compression quality level (0-100, default 75)",
+" r		output color image as RGB rather than YCbCr",
+"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality",
+"",
+"LZW and deflate options:",
+" #		set predictor value",
+"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
+" -h		this help message",
+NULL
+};
+
+static void
+usage(void)
+{
+	char buf[BUFSIZ];
+	int i;
+
+	setbuf(stderr, buf);
+        fprintf(stderr, "%s\n\n", TIFFGetVersion());
+	for (i = 0; stuff[i] != NULL; i++)
+		fprintf(stderr, "%s\n", stuff[i]);
+	exit(-1);
+}
+
+/* vim: set ts=8 sts=8 sw=8 noet: */
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 8
+ * fill-column: 78
+ * End:
+ */
--- tiff-4.0.8/tools/rasterfile.h	1970-01-01 01:00:00.000000000 +0100
+++ tiff-4.0.8/tools/rasterfile.h	2017-06-20 11:27:10.902595486 +0200
@@ -0,0 +1,44 @@
+/* $Header: /cvs/maptools/cvsroot/libtiff/archive/tools/rasterfile.h,v 1.1 2016-06-05 19:54:00 bfriesen Exp $ */
+
+#include "tiff.h"
+
+/*
+ * Description of header for files containing raster images
+ */
+struct rasterfile {
+	char	ras_magic[4];		/* magic number */
+	int32	ras_width;		/* width (pixels) of image */
+	int32	ras_height;		/* height (pixels) of image */
+	int32	ras_depth;		/* depth (1, 8, or 24 bits) of pixel */
+	int32	ras_length;		/* length (bytes) of image */
+	int32	ras_type;		/* type of file; see RT_* below */
+	int32	ras_maptype;		/* type of colormap; see RMT_* below */
+	int32	ras_maplength;		/* length (bytes) of following map */
+	/* color map follows for ras_maplength bytes, followed by image */
+};
+#define	RAS_MAGIC	"\x59\xa6\x6a\x95"
+#define	RAS_MAGIC_INV	"\x95\x6a\xa6\x59"
+
+	/* Sun supported ras_type's */
+#define RT_OLD		0	/* Raw pixrect image in 68000 byte order */
+#define RT_STANDARD	1	/* Raw pixrect image in 68000 byte order */
+#define RT_BYTE_ENCODED	2	/* Run-length compression of bytes */
+#define RT_EXPERIMENTAL 0xffff	/* Reserved for testing */
+
+	/* Sun registered ras_maptype's */
+#define RMT_RAW		2
+	/* Sun supported ras_maptype's */
+#define RMT_NONE	0	/* ras_maplength is expected to be 0 */
+#define RMT_EQUAL_RGB	1	/* red[ras_maplength/3],green[],blue[] */
+
+/*
+ * NOTES:
+ * 	Each line of the image is rounded out to a multiple of 16 bits.
+ *   This corresponds to the rounding convention used by the memory pixrect
+ *   package (/usr/include/pixrect/memvar.h) of the SunWindows system.
+ *	The ras_encoding field (always set to 0 by Sun's supported software)
+ *   was renamed to ras_length in release 2.0.  As a result, rasterfiles
+ *   of type 0 generated by the old software claim to have 0 length; for
+ *   compatibility, code reading rasterfiles must be prepared to compute the
+ *   true length from the width, height, and depth fields.
+ */
openSUSE Build Service is sponsored by