From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- graphics/degrade/README | 34 +++++++++++++++++++++++++++++++ graphics/degrade/degrade.sh | 35 ++++++++++++++++++++++++++++++++ graphics/degrade/degrade.sty | 48 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 graphics/degrade/README create mode 100644 graphics/degrade/degrade.sh create mode 100644 graphics/degrade/degrade.sty (limited to 'graphics/degrade') diff --git a/graphics/degrade/README b/graphics/degrade/README new file mode 100644 index 0000000000..9eb30564e3 --- /dev/null +++ b/graphics/degrade/README @@ -0,0 +1,34 @@ +Description: +------------ +This package degrades JPEG images on the fly to a given resolution to decrease +the size of the resulting PostScript or PDF file. + +Requirements: +------------- +You'll need the convert utility from the ImageMagick bundle and the jpeg2ps +program from CTAN if you don't use VTeX. Because of the script "degrade.sh" +this package works only on Unix-like systems. + +Installation: +------------- +Put the script "degrade.sh" in your $PATH and make it executable. +Put "degrade.sty" in a place where TeX can find it. + +Commands: +--------- +\DegSetup{key=value,...} +Known keys are: +* res to set the resolution in dpi (default=100, example: res=300) +* dir to set the directory where to put the resized jpeg files + (default=degrade) +* sdir to set the directory where images should be found in general + (default: current directory) + +\degimage[w|h]{width or height}{image} +Use this instead of \includegraphics to include your image. +example 1: \degimage{\linewidth}{flower}, +example 2: \degimage[h]{0.5\textheight}{power} + +Author: +------- +Peter Münster, email: pmrb at free.fr diff --git a/graphics/degrade/degrade.sh b/graphics/degrade/degrade.sh new file mode 100644 index 0000000000..197b42a4d6 --- /dev/null +++ b/graphics/degrade/degrade.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +## This script and the LaTeX extension "degrade.sty" may be distributed +## under the conditions of the LaTeX Project Public License +## (http://www.latex-project.org/lppl.txt). + +X= +[ $1 = h ]&&X=x +FORMAT="%$1" +FILE="$5/$2.jpg" +DFILE="$6/$2.jpg" +DPI="$3" +IW="$4" +EXT="$7" +INCH=72.27 + +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" + [ $EXT = EPS ]&&jpeg2ps "$DFILE" >"${DFILE/.jpg/.eps}" + fi +fi diff --git a/graphics/degrade/degrade.sty b/graphics/degrade/degrade.sty new file mode 100644 index 0000000000..a4ab33e0f0 --- /dev/null +++ b/graphics/degrade/degrade.sty @@ -0,0 +1,48 @@ +%% degrade.sty +%% © 2002 by Peter Münster +%% +%% A package, that degrades JPEG images on the fly to decrease the size of the +%% resulting PostScript or PDF file. You'll need the convert utility from the +%% ImageMagick bundle and the jpeg2ps program from CTAN if you don't use VTeX. +%% +%% It may be distributed under the conditions of the LaTeX Project Public +%% License (http://www.latex-project.org/lppl.txt). +%% +%% Commands: +%% +%% \DegSetup{key=value,...} Known keys are: +%% * res to set the resolution in dpi (default=100, example: res=300) +%% * dir to set the directory where to put the resized jpeg files +%% (default=degrade) +%% * sdir to set the directory where images should be found in general +%% (default: current directory) +%% +%% \degimage[w|h]{width or height}{image} Use this instead of \includegraphics +%% to include your image. +%% example 1: \degimage{\linewidth}{flower}, +%% example 2: \degimage[h]{0.5\textheight}{power} +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{degrade} +\RequirePackage{ifvtex,graphicx} + +%% default values: +\newcommand*\Deg@Res{100}% 220 is good for seminar with 1024x768 display +\newcommand*\Deg@Dir{degrade}% directory for degraded images +\newcommand*\Deg@SDir{.}% source directory + +\define@key{degrade}{res}{\renewcommand*\Deg@Res{#1}} +\define@key{degrade}{dir}{\renewcommand*\Deg@Dir{#1}} +\define@key{degrade}{sdir}{\renewcommand*\Deg@SDir{#1}\graphicspath{{#1/}}} + +\newcommand*\DegSetup[1]{\setkeys{degrade}{#1}} +\newlength\@TEMPW + +\ifvtex\else\def\command{\immediate\write18}\typeout{You have to run LaTeX + with the --shell-escape option.}\fi + +\newcommand\degimage[3][w]{\setlength\@TEMPW{#2}\command{degrade.sh #1 #3 + \Deg@Res\space\strip@pt\@TEMPW\space\Deg@SDir\space\Deg@Dir\space\ifvtex + JPG\else EPS\fi}\if#1w\def\Deg@WH{width}\else\def\Deg@WH{height}\fi + \IfFileExists{\Deg@Dir/#3.jpg}{\def\Deg@File{\Deg@Dir/#3}}{% + \def\Deg@File{#3}}\includegraphics*[\Deg@WH=#2]{\Deg@File}} -- cgit v1.2.3