Changes

Jump to navigation Jump to search
== ImageMagick ==
''ImageMagick® '' ([http://www.imagemagick.org/script/index.php here] ) ''is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
''
There are at least two python bindings, and this time I consider
[http://www.procoders.net/?p=39 PythonMagickWand] which is a binding "ala" ctypes way .
Code is simple
<texcode>
\usetypescriptfile[type-gentium]
\usetypescript[gentium]
\setupbodyfont[gentium,10pt]
\setuppapersize[A5][A5]
\setuplayout[height=middle,topspace=1cm,header={2\lineheight},footer=0pt,backspace=1cm,margin=1cm, width=middle]
 
 
\startluacode
function testimagemagick(box,t)
local w
local h
local d
local f
local res = 118.11023622047244094488 -- 300 dpi
local opacity = 25
local sigma = 15
local x = 10
local y = 10
 
require("python")
pg = python.globals()
PythonMagickWand = python.import("PythonMagickWand")
w = math.floor((tex.wd[box] / 65536 ) / 72.27 * 2.54 * res )
h = math.floor(((tex.ht[box] / 65536) + (tex.dp[box] / 65536)) / 72.27 *2.54 *res )
f = string.format("%s.png",t)
 
wand = PythonMagickWand.NewMagickWand()
background = PythonMagickWand.NewPixelWand(0)
-- PythonMagickWand.MagickNewImage(wand,w,h,background)
PythonMagickWand.MagickNewImage(wand,w,h,background)
 
PythonMagickWand.MagickSetImageResolution(wand,res,res)
PythonMagickWand.MagickSetImageUnits(wand,PythonMagickWand.PixelsPerCentimeterResolution)
PythonMagickWand.MagickShadowImage(wand,opacity,sigma,x,y)
PythonMagickWand.MagickWriteImage(wand ,f)
 
print(w,h,f)
end
\stopluacode
 
 
 
 
\def\testimagemagick[#1]{%
\getparameters[imagemagick][#1]%
\ctxlua{testimagemagick(\csname imagemagickbox\endcsname,"\csname imagemagickfilename\endcsname")}%
}
 
\newcount\shdw
\long\def\startShadowtext#1\stopShadowtext{%
\bgroup%
\setbox0=\vbox{#1}%
\testimagemagick[box=0,filename={shd-\the\shdw}]%
%%
\defineoverlay[backg][{\externalfigure[shd-\the\shdw.png]}]%
\framed[background=backg,frame=off,offset=4pt]{\box0}%
%%\framed{\box0}
\global\advance\shdw by 1%
\egroup%
}
 
\starttext
\startTEXpage%
\startShadowtext%
\input tufte
\stopShadowtext%
\stopTEXpage
\stoptext
</texcode>
== Fontforge ==

Navigation menu