summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/context/third/degrade/degrade-demo.pdfbin0 -> 20889 bytes
-rw-r--r--Master/texmf-dist/doc/context/third/degrade/degrade-doc.pdfbin0 -> 169975 bytes
-rw-r--r--Master/texmf-dist/tex/context/third/degrade/t-degrade.tex163
-rw-r--r--Master/texmf-dist/tpm/t-degrade.tpm31
-rw-r--r--Master/tlpkg/tlpsrc/collection-context.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/context-degrade.tlpsrc4
6 files changed, 199 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/context/third/degrade/degrade-demo.pdf b/Master/texmf-dist/doc/context/third/degrade/degrade-demo.pdf
new file mode 100644
index 00000000000..5a9d3e1558b
--- /dev/null
+++ b/Master/texmf-dist/doc/context/third/degrade/degrade-demo.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/context/third/degrade/degrade-doc.pdf b/Master/texmf-dist/doc/context/third/degrade/degrade-doc.pdf
new file mode 100644
index 00000000000..1d3f34abd28
--- /dev/null
+++ b/Master/texmf-dist/doc/context/third/degrade/degrade-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/context/third/degrade/t-degrade.tex b/Master/texmf-dist/tex/context/third/degrade/t-degrade.tex
new file mode 100644
index 00000000000..b2dbba495c3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/third/degrade/t-degrade.tex
@@ -0,0 +1,163 @@
+%D \enableregime[utf]
+%D \module
+%D [ file=t-degrade,
+%D version=2006.09.12,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Degrading JPEG images,
+%D author=Peter Münster,
+%D date=\currentdate,
+%D copyright={Peter Münster}]
+%C This module is copyrighted by Peter Münster.
+%C Please send any comments to pmrb at free.fr.
+
+% This program is free software; you can redistribute it and/or
+% modify it under the terms of the GNU General Public License
+% as published by the Free Software Foundation; either version 2
+% of the License, or (at your option) any later version.
+
+% This program is distributed in the hope that it will be useful,
+% but without any warranty; without even the implied warranty of
+% merchantability or fitness for a particular purpose. See the
+% GNU General Public License for more details.
+
+\writestatus{loading}{Degrading JPEG images on the fly}
+
+\unprotect
+
+%D In this module we suppose, that original figures are either eps or jpg.
+%D When creating pdf, eps is converted to pdf, and when creating dvi,
+%D jpg is converted to eps.
+%D Furthermore, jpg-images can be degraded to a given resolution, to get
+%D smaller documents.
+
+%D When
+%D \type{http://context.literatesolutions.com/collector/63}
+%D is solved, we can make it better using \type{\appliedfigurefilename},
+%D \type{\figurewidth} etc, and without redefining \type{\externalfigure}.
+
+%D \macros{setupDegrade}
+%D Sets the resolution, the directory for degraded images and the
+%D directory, where the original images can be found (source directory).
+%D
+%D Default setup:
+%D
+%D \starttyping
+%D \setupDegrade[Res=100,Dir=degrade,SDir=.]
+%D \stoptyping
+%D
+%D Example:
+%D
+%D \starttyping
+%D \setupDegrade[Res=600,Dir=degraded-images,SDir=/home/peter/jpegs]
+%D \stoptyping
+
+\def\setupDegrade[#1]{\getparameters[Deg][#1]}
+\setupDegrade[Res=100,Dir=degrade,SDir=.]
+
+%D In order to use this module, you must use \type{\externalfigure}
+%D in the following way: \type{\externalfigure[file-prefix][options]},
+%D where \type{options} must contain the width or the height.
+%D Furthermore, \type{\write18} must be enabled.
+%D The shell-script is in a buffer, just to keep this module in only
+%D one file.
+
+\startbuffer[degrade-script]
+#!/bin/bash
+
+# We consider, that original figures are either eps or jpg.
+
+# Arguments:
+# $1 = filename
+# $2 = eps or pdf
+# $3 = w or h
+# $4 = resolution
+# $5 = dimension of image
+# $6 = source directory
+# $7 = destination directory
+
+for i in jpeg2ps convert identify bc; do
+ if ! type $i &>/dev/null; then
+ echo Error: $i is not installed.
+ exit 1
+ fi
+done
+
+EPSTOPDF=epstopdf
+
+if ! type epstopdf &>/dev/null; then
+ if type texmfstart &>/dev/null; then
+ EPSTOPDF="texmfstart newpstopdf"
+ else
+ EPSTOPDF="texutil --figures --epstopdf"
+ fi
+fi
+
+if [ -s "$1.jpg" ]; then
+ if [ "$2" = eps ] && [ "$1.jpg" -nt "$1.eps" ]; then
+ jpeg2ps "$1.jpg" >"$1.eps"
+ fi
+else
+ if [ "$2" = pdf ] && [ "$1.eps" -nt "$1.pdf" ]; then
+ $EPSTOPDF "$1.eps"
+ fi
+fi
+
+X=
+[ $3 = h ] && X=x
+FORMAT="%$3"
+FILE="$6/$1.jpg"
+DFILE="$7/$1.jpg"
+DFILE_EPS="$7/$1.eps"
+DPI="$4"
+IW="$5"
+MODE="$2"
+INCH=72.27
+
+mkdir -p $7
+
+if [ -s "$FILE" ]; then
+ W=`identify -format "$FORMAT" "$FILE"`
+else
+ rm -f "$DFILE"
+ exit 0
+fi
+
+NW=`echo "$DPI * $IW / $INCH" | bc`
+
+if [ $NW -ge $W ]; then
+ rm -f "$DFILE"
+else
+ if [ -s "$DFILE" ] && \
+ [ `identify -format "$FORMAT" "$DFILE"` -eq $NW ]; then
+ exit 0
+ else
+ convert -verbose -resize $X$NW "$FILE" "$DFILE"
+ [ $MODE = eps ] && jpeg2ps "$DFILE" >"$DFILE_EPS"
+ fi
+fi
+\stopbuffer
+
+\def\Command{\immediate\write18}
+\let\externalfigureO=\externalfigure
+\def\externalfigure[#1][#2]{%
+ \getparameters[Deg][height=,#2]%
+ \processaction[\Degheight][%
+ \s!default =>\scratchdimen=\Degwidth \def\Deg@WH{w},
+ \s!unknown =>\scratchdimen=\Degheight \def\Deg@WH{h}]%
+ \Command{bash ./\jobname-degrade-script.tmp #1 \ifcase\pdfoutput eps\else
+ pdf\fi\space\Deg@WH\space\DegRes\space\withoutpt\the\scratchdimen\space
+ \DegSDir\space\DegDir}%
+ \doiffileexistselse{\DegDir/#1.jpg}{\def\Deg@File{\DegDir/#1}}{%
+ \def\Deg@File{#1}}%
+ \externalfigureO[\Deg@File][#2]}
+
+\protect
+
+\doifnotmode{demo}{\endinput}
+
+%D Usage example:
+%\usemodule[degrade]
+% \setupDegrade[Res=200] Here you can adjust the resolution (unit = dpi).
+\starttext
+\externalfigure[hacker][width=0.2\textwidth]
+\stoptext
diff --git a/Master/texmf-dist/tpm/t-degrade.tpm b/Master/texmf-dist/tpm/t-degrade.tpm
new file mode 100644
index 00000000000..2aa02a12393
--- /dev/null
+++ b/Master/texmf-dist/tpm/t-degrade.tpm
@@ -0,0 +1,31 @@
+<!DOCTYPE rdf:RDF SYSTEM "tpm.dtd">
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:TPM="http://texlive.dante.de/">
+ <rdf:Description about="http://dl.contextgarden.net/modules/t-degrade.zip">
+ <TPM:Name>t-degrade</TPM:Name>
+ <TPM:Type>Package</TPM:Type>
+ <TPM:Date>2006/09/12 00:00:00</TPM:Date>
+ <TPM:Version>2006.09.12</TPM:Version>
+ <TPM:Creator>Peter</TPM:Creator>
+ <TPM:Title>Degrading JPEG images</TPM:Title>
+ <TPM:Description>
+This module degrades jepg-images on the fly to a given resolution, if some
+additional software is installed (epstopdf, jpeg2ps, convert, identify,
+bc).
+ </TPM:Description>
+ <TPM:Author>Peter Münster</TPM:Author>
+ <TPM:Size>196368</TPM:Size>
+ <TPM:Build/>
+ <TPM:RunFiles size="5504">
+tex/context/third/degrade/t-degrade.tex
+tpm/t-degrade.tpm
+ </TPM:RunFiles>
+ <TPM:DocFiles size="190864">
+doc/context/third/degrade/degrade-doc.pdf
+doc/context/third/degrade/degrade-demo.pdf
+ </TPM:DocFiles>
+ <TPM:Requires>
+ <TPM:Package name="context"/>
+ </TPM:Requires>
+ <TPM:Provides>Package/t-degrade</TPM:Provides>
+ </rdf:Description>
+</rdf:RDF>
diff --git a/Master/tlpkg/tlpsrc/collection-context.tlpsrc b/Master/tlpkg/tlpsrc/collection-context.tlpsrc
index d8b0ca7d040..f17b9fb5916 100644
--- a/Master/tlpkg/tlpsrc/collection-context.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-context.tlpsrc
@@ -10,6 +10,7 @@ depend context-account
depend context-bnf
depend context-chromato
depend context-construction-plan
+depend context-degrade
depend context-french
depend collection-metapost
depend collection-basic
diff --git a/Master/tlpkg/tlpsrc/context-degrade.tlpsrc b/Master/tlpkg/tlpsrc/context-degrade.tlpsrc
new file mode 100644
index 00000000000..f262525f88f
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/context-degrade.tlpsrc
@@ -0,0 +1,4 @@
+name context-degrade
+category Package
+runpattern d texmf-dist/tex/context/third/degrade
+docpattern d texmf-dist/doc/context/third/degrade