Difference between revisions of "Downsampling"
(new page, first save) |
m (outdated hint) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
Downsampling means to reduce the resolution of a picture to save space. | Downsampling means to reduce the resolution of a picture to save space. | ||
− | + | There’s a solution outlined in [[Using_Graphics#Image_Conversion]]; the rest of this page is outdated. | |
== grph-downsample == | == grph-downsample == | ||
− | This MkIV module is not in the distribution, but you can download it from [http://modules.contextgarden.net/grph-downsample here]. It expects the <code>gm</code> tool from [http://www.graphicsmagick.org GraphicsMagick] to be callable. | + | '''This doesn’t work any more; it was a bit better than the script in [[Using_Graphics#Image_Conversion]].''' |
+ | |||
+ | This MkIV module is not in the distribution and not documented, but you can download it from [http://modules.contextgarden.net/grph-downsample here]. It expects the <code>gm</code> tool from [http://www.graphicsmagick.org GraphicsMagick] to be callable and works on PNG, JPG and GIF pictures. | ||
Copy grph-downsample.lua to <code>.../texmf-local/tex/context/third/grph-downsample/grph-downsample.lua</code> | Copy grph-downsample.lua to <code>.../texmf-local/tex/context/third/grph-downsample/grph-downsample.lua</code> | ||
Line 31: | Line 33: | ||
== t-degrade == | == t-degrade == | ||
+ | |||
+ | This MkII module is in the distribution, but also available [http://modules.contextgarden.net/t-degrade here]. It works only on JPG pictures and has some [http://modules.contextgarden.net/dl/t-degrade/doc/context/third/degrade/degrade-doc.pdf documentation]. | ||
+ | |||
+ | {{cmd|setupDegrade}} understands the keys <code>Res</code>, <code>Dir</code>, <code>SDir</code>: | ||
+ | * Res = resolution in dpi (default: 100) | ||
+ | * Dir = target directory for degraded images (default: degrade) | ||
+ | * SDir = source directory of original images (default: .) | ||
+ | |||
+ | This modules works only if the if the <code>width</code> or <code>height</code> key of {{cmd|externalfigure}} is defined. or <code>height</code> key of {{cmd|externalfigure}} is defined. | ||
+ | |||
+ | It creates a Bash (shell) script and calls the tools <code>jpeg2ps</code>, <code>epstopdf</code> or <code>texutil</code>, <code>identify</code> and <code>convert</code>. | ||
+ | |||
+ | <texcode> | ||
+ | \usemodule[degrade] | ||
+ | \setupDegrade[Res=10, Dir=temp, SDir=.] | ||
+ | \starttext | ||
+ | \externalfigure[hacker.jpg][width=5cm] | ||
+ | \stoptext | ||
+ | </texcode> | ||
+ | |||
+ | |||
+ | [[Category:Graphics]] |
Latest revision as of 10:20, 12 August 2022
< Using Graphics >
Downsampling means to reduce the resolution of a picture to save space.
There’s a solution outlined in Using_Graphics#Image_Conversion; the rest of this page is outdated.
grph-downsample
This doesn’t work any more; it was a bit better than the script in Using_Graphics#Image_Conversion.
This MkIV module is not in the distribution and not documented, but you can download it from here. It expects the gm
tool from GraphicsMagick to be callable and works on PNG, JPG and GIF pictures.
Copy grph-downsample.lua to .../texmf-local/tex/context/third/grph-downsample/grph-downsample.lua
Call context --generate
Copy hacker.jpg
to your directory.
Write this to downsample.tex
:
\loadluafile[grph-downsample] \setupexternalfigures[conversion=lowres.jpg, resolution=10] \starttext \externalfigure[hacker.jpg][width=5cm] \stoptext
The module extends \setupexternalfigures with the conversion
and resolution
keys. The former defines an extension to the filename, the latter the final resolution dpi. It works only if the width
or height
key of \externalfigure is defined.
conversion=lowres.jpg
in the above example creates a temporary file m_k_i_v_hacker.jpg_10.lowres.jpg
.
t-degrade
This MkII module is in the distribution, but also available here. It works only on JPG pictures and has some documentation.
\setupDegrade understands the keys Res
, Dir
, SDir
:
- Res = resolution in dpi (default: 100)
- Dir = target directory for degraded images (default: degrade)
- SDir = source directory of original images (default: .)
This modules works only if the if the width
or height
key of \externalfigure is defined. or height
key of \externalfigure is defined.
It creates a Bash (shell) script and calls the tools jpeg2ps
, epstopdf
or texutil
, identify
and convert
.
\usemodule[degrade] \setupDegrade[Res=10, Dir=temp, SDir=.] \starttext \externalfigure[hacker.jpg][width=5cm] \stoptext