kopia lustrzana https://gitlab.com/sane-project/website
				
				
				
			
		
			
	
	
		
			253 wiersze
		
	
	
		
			7.9 KiB
		
	
	
	
		
			HTML
		
	
	
		
		
			
		
	
	
			253 wiersze
		
	
	
		
			7.9 KiB
		
	
	
	
		
			HTML
		
	
	
|   | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" | ||
|  |                       "http://www.w3.org/TR/REC-html40/loose.dtd"> | ||
|  | <HTML> | ||
|  | <HEAD> | ||
|  | <TITLE>sane-devel: A simple scheme to produce arbitrary output formats</TITLE> | ||
|  | <META NAME="Author" CONTENT="Stefan Illy (stefan.illy@ihm.fzk.de)"> | ||
|  | <META NAME="Subject" CONTENT="A simple scheme to produce arbitrary output formats"> | ||
|  | </HEAD> | ||
|  | <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> | ||
|  | <H1>A simple scheme to produce arbitrary output formats</H1> | ||
|  | <!-- received="Tue Aug 15 02:26:00 2000" --> | ||
|  | <!-- isoreceived="20000815092600" --> | ||
|  | <!-- sent="Tue, 15 Aug 2000 11:30:11 +0200 (CEST)" --> | ||
|  | <!-- isosent="20000815093011" --> | ||
|  | <!-- name="Stefan Illy" --> | ||
|  | <!-- email="stefan.illy@ihm.fzk.de" --> | ||
|  | <!-- subject="A simple scheme to produce arbitrary output formats" --> | ||
|  | <!-- id="14745.3491.849563.564819@ihmgyro5.fzk.de" --> | ||
|  | <STRONG>From:</STRONG> Stefan Illy (<A HREF="mailto:stefan.illy@ihm.fzk.de?Subject=Re:%20A%20simple%20scheme%20to%20produce%20arbitrary%20output%20formats&In-Reply-To=<14745.3491.849563.564819@ihmgyro5.fzk.de>"><EM>stefan.illy@ihm.fzk.de</EM></A>)<BR> | ||
|  | <STRONG>Date:</STRONG> Tue Aug 15 2000 - 02:30:11 PDT | ||
|  | <P> | ||
|  | <!-- next="start" --> | ||
|  | <LI><STRONG>Next message:</STRONG> <A HREF="0133.html">Jochen Eisinger: "bug in mustek_pp"</A> | ||
|  | <UL> | ||
|  | <LI><STRONG>Previous message:</STRONG> <A HREF="0131.html">Chris Pinkham: "Re: sane-1.0.3 released"</A> | ||
|  | <!-- nextthread="start" --> | ||
|  | <LI><STRONG>Next in thread:</STRONG> <A HREF="0160.html">Henning Meier-Geinitz: "Re: A simple scheme to produce arbitrary output formats"</A> | ||
|  | <LI><STRONG>Reply:</STRONG> <A HREF="0160.html">Henning Meier-Geinitz: "Re: A simple scheme to produce arbitrary output formats"</A> | ||
|  | <!-- reply="end" --> | ||
|  | <LI><STRONG>Messages sorted by:</STRONG>  | ||
|  | <A HREF="date.html#132">[ date ]</A> | ||
|  | <A HREF="index.html#132">[ thread ]</A> | ||
|  | <A HREF="subject.html#132">[ subject ]</A> | ||
|  | <A HREF="author.html#132">[ author ]</A> | ||
|  | </UL> | ||
|  | <HR NOSHADE><P> | ||
|  | <!-- body="start" --> | ||
|  | <P> | ||
|  | I'm not very happy with the fact that xscanimage can produce only | ||
|  | <BR> | ||
|  | pnm-output. | ||
|  | <BR> | ||
|  | <P>By adding a couple of lines to xscanimage.c and providing an additional | ||
|  | <BR> | ||
|  | shell script I could get easily around this problem. | ||
|  | <BR> | ||
|  | <P>My scheme is quite simple: | ||
|  | <BR> | ||
|  | <P>The user specifies the requested output format by the suffix of the | ||
|  | <BR> | ||
|  | output file (e.g. `output.eps'). | ||
|  | <BR> | ||
|  | <P>After the fclose() call in xscanimage.c the program will check for the | ||
|  | <BR> | ||
|  | SANE_CONVERT environment variable. If it exists it will call the | ||
|  | <BR> | ||
|  | program specified in SANE_CONVERT, in my case a shell script called | ||
|  | <BR> | ||
|  | `sane-convert'. This program takes one argument, the name of the | ||
|  | <BR> | ||
|  | output file and will convert it to the requested format using | ||
|  | <BR> | ||
|  | ImageMagick or the netpbm utilities. | ||
|  | <BR> | ||
|  | <P>Here are the changes I had to apply to xscanimage.c  | ||
|  | <BR> | ||
|  | (line 760+, 7 additinoal lines): | ||
|  | <BR> | ||
|  |     { | ||
|  | <BR> | ||
|  | +     char *saneconvert, cmd[2*PATH_MAX]; | ||
|  | <BR> | ||
|  |       fclose (scan_win.out); | ||
|  | <BR> | ||
|  |       scan_win.out = 0; | ||
|  | <BR> | ||
|  | +     if ((saneconvert = getenv("SANE_CONVERT")) != NULL) | ||
|  | <BR> | ||
|  | +     { | ||
|  | <BR> | ||
|  | +       strcpy(cmd, saneconvert); | ||
|  | <BR> | ||
|  | +       strcat(cmd, preferences.filename); | ||
|  | <BR> | ||
|  | +       strcat(cmd, " "); | ||
|  | <BR> | ||
|  | +       system(cmd); | ||
|  | <BR> | ||
|  |       } | ||
|  | <BR> | ||
|  |     } | ||
|  | <BR> | ||
|  | <P><P>And this is the sane-convert shell script: | ||
|  | <BR> | ||
|  | -------------snip------------------------- | ||
|  | <BR> | ||
|  | #!/bin/sh | ||
|  | <BR> | ||
|  | # | ||
|  | <BR> | ||
|  | #  sane-convert: convert a pnm-file generated by xscanimage to a  | ||
|  | <BR> | ||
|  | #                user-specified format  | ||
|  | <BR> | ||
|  | #                (determined by the filename's suffix). | ||
|  | <BR> | ||
|  | # | ||
|  | <BR> | ||
|  | <P>SCRIPT=`basename $0` | ||
|  | <BR> | ||
|  | <P># | ||
|  | <BR> | ||
|  | #  Argument checking. | ||
|  | <BR> | ||
|  | # | ||
|  | <BR> | ||
|  | if [ $# -ne 1 ]; then | ||
|  | <BR> | ||
|  |   echo "$SCRIPT: invalid number of arguments." 1>&2 | ||
|  | <BR> | ||
|  |   exit 1 | ||
|  | <BR> | ||
|  | fi | ||
|  | <BR> | ||
|  | <P>if [ ! -r $1 ]; then | ||
|  | <BR> | ||
|  |   echo "$SCRIPT: input file \`$1' is not readable." 1>&2 | ||
|  | <BR> | ||
|  |   exit 2 | ||
|  | <BR> | ||
|  | fi | ||
|  | <BR> | ||
|  | <P># | ||
|  | <BR> | ||
|  | #  Input and output filenames. | ||
|  | <BR> | ||
|  | # | ||
|  | <BR> | ||
|  | INPUT=$1-$$.pnm | ||
|  | <BR> | ||
|  | OUTPUT=$1 | ||
|  | <BR> | ||
|  | <P># | ||
|  | <BR> | ||
|  | #  Specification of the conversion filters (CHANGE TO YOUR NEEDS!). | ||
|  | <BR> | ||
|  | # | ||
|  | <BR> | ||
|  | case $OUTPUT in | ||
|  | <BR> | ||
|  |   *.p[bgpn]m)   echo "$SCRIPT: pnm format, conversion skipped." | ||
|  | <BR> | ||
|  |                 exit 0 | ||
|  | <BR> | ||
|  |                 ;; | ||
|  | <BR> | ||
|  |   *.eps)        CONVERT="convert $INPUT eps2:$OUTPUT" | ||
|  | <BR> | ||
|  |                 ;; | ||
|  | <BR> | ||
|  |   *.ps)         CONVERT="convert -page A4 -border 36x36 -bordercolor white \ | ||
|  | <BR> | ||
|  |                                  -rotate -90\> $INPUT ps2:$OUTPUT" | ||
|  | <BR> | ||
|  |                 ;; | ||
|  | <BR> | ||
|  |   *.jpg)        CONVERT="cjpeg -quality 75 < $INPUT > $OUTPUT" | ||
|  | <BR> | ||
|  |                 ;; | ||
|  | <BR> | ||
|  |   *)            CONVERT="convert $INPUT $OUTPUT" | ||
|  | <BR> | ||
|  |                 ;; | ||
|  | <BR> | ||
|  | esac | ||
|  | <BR> | ||
|  | <P>echo "$SCRIPT: running \`$CONVERT'..." | ||
|  | <BR> | ||
|  | <P># | ||
|  | <BR> | ||
|  | #  The converstion step. | ||
|  | <BR> | ||
|  | # | ||
|  | <BR> | ||
|  | mv $OUTPUT $INPUT && sh -c "$CONVERT" | ||
|  | <BR> | ||
|  | if [ $? -eq 0 ]; then | ||
|  | <BR> | ||
|  |   echo "$SCRIPT: conversion completed successfully." | ||
|  | <BR> | ||
|  | else | ||
|  | <BR> | ||
|  |   echo "$SCRIPT: conversion failed." | ||
|  | <BR> | ||
|  | fi | ||
|  | <BR> | ||
|  | <P># | ||
|  | <BR> | ||
|  | #  Deleting the input file. | ||
|  | <BR> | ||
|  | # | ||
|  | <BR> | ||
|  | rm $INPUT | ||
|  | <BR> | ||
|  | -------------snip------------------------- | ||
|  | <BR> | ||
|  | <P>What do you think of this concept? | ||
|  | <BR> | ||
|  | <P>Maybe it is a candidate for sane-1.0.4? | ||
|  | <BR> | ||
|  | <P><P>Best regards, | ||
|  | <BR> | ||
|  | <P>Stefan | ||
|  | <BR> | ||
|  | <P><P><PRE> | ||
|  | --  | ||
|  | Stefan Illy                     |  Institut fuer Hochleistungsimpuls- | ||
|  |                                 |  und Mikrowellentechnik (IHM) | ||
|  | e-mail: <A HREF="mailto:stefan.illy@ihm.fzk.de?Subject=Re:%20A%20simple%20scheme%20to%20produce%20arbitrary%20output%20formats&In-Reply-To=<14745.3491.849563.564819@ihmgyro5.fzk.de>">stefan.illy@ihm.fzk.de</A>  |  Forschungszentrum Karlsruhe GmbH | ||
|  | phone:  (+49) 07247/82-4165     |  Postfach 3640 | ||
|  | fax:    (+49) 07247/82-4874     |  D-76021 Karlsruhe, Germany | ||
|  | <P><P>-- | ||
|  | Source code, list archive, and docs: <A HREF="http://www.mostang.com/sane/">http://www.mostang.com/sane/</A> | ||
|  | To unsubscribe: echo unsubscribe sane-devel | mail <A HREF="mailto:majordomo@mostang.com?Subject=Re:%20A%20simple%20scheme%20to%20produce%20arbitrary%20output%20formats&In-Reply-To=<14745.3491.849563.564819@ihmgyro5.fzk.de>">majordomo@mostang.com</A> | ||
|  | </PRE> | ||
|  | <P><!-- body="end" --> | ||
|  | <HR NOSHADE> | ||
|  | <UL> | ||
|  | <!-- next="start" --> | ||
|  | <LI><STRONG>Next message:</STRONG> <A HREF="0133.html">Jochen Eisinger: "bug in mustek_pp"</A> | ||
|  | <LI><STRONG>Previous message:</STRONG> <A HREF="0131.html">Chris Pinkham: "Re: sane-1.0.3 released"</A> | ||
|  | <!-- nextthread="start" --> | ||
|  | <LI><STRONG>Next in thread:</STRONG> <A HREF="0160.html">Henning Meier-Geinitz: "Re: A simple scheme to produce arbitrary output formats"</A> | ||
|  | <LI><STRONG>Reply:</STRONG> <A HREF="0160.html">Henning Meier-Geinitz: "Re: A simple scheme to produce arbitrary output formats"</A> | ||
|  | <!-- reply="end" --> | ||
|  | <LI><STRONG>Messages sorted by:</STRONG>  | ||
|  | <A HREF="date.html#132">[ date ]</A> | ||
|  | <A HREF="index.html#132">[ thread ]</A> | ||
|  | <A HREF="subject.html#132">[ subject ]</A> | ||
|  | <A HREF="author.html#132">[ author ]</A> | ||
|  | </UL> | ||
|  | <!-- trailer="footer" --> | ||
|  | <HR NOSHADE> | ||
|  | <P> | ||
|  | <SMALL> | ||
|  | <EM> | ||
|  | This archive was generated by <A HREF="http://www.hypermail.org/">hypermail 2b29</A>  | ||
|  | : <EM>Tue Aug 15 2000 - 02:28:00 PDT</EM> | ||
|  | </EM> | ||
|  | </SMALL> | ||
|  | </BODY> | ||
|  | </HTML> |