Re: [NTG-context] setupexternalfigures and resoĺution
Am 01.09.22 um 15:04 schrieb Henning Hraban Ramm via ntg-context: Am 01.09.22 um 13:43 schrieb juh+ntg-context--- via ntg-context: Am 01.09.22 um 10:51 schrieb Henning Hraban Ramm via ntg-context: \loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }% \setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ] With the script I get strange results. I am not sure whether the resolution is correctly calculated. And I am wondering what the script is doing with png files. This one attacks all images, but it doesn’t calculate the final size correctly. For the records. I need a resolution of 240 to get a good looking image. This is more or less the same quality with 150 using the other possibility. After playing around this day I fear that postprocessing with ps2pdf is more predictable and results in a way more tiny file. juh ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] update old MP code
Am 01.09.22 um 18:45 schrieb Taco Hoekwater: On 1 Sep 2022, at 18:28, Henning Hraban Ramm via ntg-context wrote: Am 01.09.22 um 15:40 schrieb Taco Hoekwater: Adding grouping makes sense: def Moire(expr size)(text densities)= begingroup endgroup As that at least makes it an expression instead of a statement list. But also depthless() is never defined? Oops, I forgot to copy that part (confusing source...) It still doesn’t compile: Missing definition of “width()”, from this line: xs := width(q)-width(p); Adding that should do the trick. YES, thank you! I never know which function is part of MetaPost/MetaFun, my editor’s syntax highlighting is incomplete... Hraban moireetest.tex Description: TeX document ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] update old MP code
> On 1 Sep 2022, at 18:28, Henning Hraban Ramm via ntg-context > wrote: > > Am 01.09.22 um 15:40 schrieb Taco Hoekwater: >> Adding grouping makes sense: >>> >>> def Moire(expr size)(text densities)= >> begingroup >> endgroup >> As that at least makes it an expression instead of a statement list. >> But also depthless() is never defined? > > Oops, I forgot to copy that part (confusing source...) > > It still doesn’t compile: Missing definition of “width()”, from this line: > > xs := width(q)-width(p); Adding that should do the trick. Best wishes. Taco — Taco Hoekwater E: t...@bittext.nl genderfluid (all pronouns) ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to make a reference go to an exact point of a section on a page?
On 9/1/22 14:36, amano.kenji via ntg-context wrote: > I just created a reference to a \section with \in. > > Clicking the \in reference doesn't go to the \section, but to the > page that has the \section. > > Does ConTeXt lack the ability to go to an exact point of a numbered > element on a page? Hi Amano, please, provide a minimal sample with your questions. Sometimes it is not easy for the rest of the world to figure out what each of us may have in mind. I hope any of the options might help you: \setupinteraction[state=start,focus=standard] \starttext \chapter[one]{One} in \in[two] or \about[two] \chapter[two]{Two} in \in[one] or \about[one] \stoptext Just in case it helps, Pablo ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] update old MP code
Am 01.09.22 um 15:40 schrieb Taco Hoekwater: Adding grouping makes sense: def Moire(expr size)(text densities)= begingroup endgroup As that at least makes it an expression instead of a statement list. But also depthless() is never defined? Oops, I forgot to copy that part (confusing source...) It still doesn’t compile: --- \setupbodyfont[plex,ss,8bp] \startreusableMPgraphic{moiree} % 1994 by Bogusław Jackowski (GUST) defaultfont := "\truefontname{Sans}"; pickup pencircle scaled 0.3bp; defaultscale := .8; linecap := butt; labeloffset := 1.5bp; defaultthickness:=.3bp; % 5 pixels at 1200 dpi % tertiarydef p ulshiftedto s = p shifted (s-ulcorner(p)) enddef; vardef depthless(expr p) = save p_; picture p_; p_:=p if string p: infont defaultfont scaled defaultscale fi; setbounds p_ to (xpart(llcorner p_),0)--(xpart(lrcorner p_),0)-- urcorner(p_)--ulcorner(p_)--cycle; p_ enddef; def Moire(expr size)(text densities)= begingroup save dn,a,b,k,labit,n,p,q,s,xs; n := 32; dn := 0; for i := densities: d[incr dn] := abs(i); if i>1: labit[dn]:=1; fi endfor a := min(d[1],d[dn]); b := max(d[1],d[dn]); image( for i=-n upto n: draw (0,i*in/a)--(size,i*in/b); %withpen pencircle scaled 3/5defaultthickness; endfor for i=1 upto dn: k:=(a/d[i]-1)/(a/b-1); if known labit[i]: string s; s:=decimal(d[i]); xs:=0; picture p,q; q := p := depthless(s); if i=dn: q := depthless(s & " lpi"); xs := width(q)-width(p); fi label.top(q, (k*size+1/2xs, n*in/a+1.5mm)); fi draw (k*size, n*in/a+1.5mm)--(k*size, k[n*in/a,n*in/b]+.5mm); draw (k*size, -n*in/a-1.5mm)--(k*size, -k[n*in/a,n*in/b]-.5mm); endfor ) endgroup; enddef; draw Moire(57.5mm)(200, 175, 150, 125, 100, 75); % ulshiftedto (142mm, 38.5mm); \stopreusableMPgraphic \starttext \reuseMPgraphic{moiree} \stoptext moireetest.tex Description: TeX document ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] update old MP code
Hi Hraban, Adding grouping makes sense: > > def Moire(expr size)(text densities)= begingroup > save dn,a,b,k,labit,n,p,q,s,xs; > n := 32; > dn := 0; > for i := densities: >d[incr dn] := abs(i); >if i>1: labit[dn]:=1; fi > endfor > a := min(d[1],d[dn]); > b := max(d[1],d[dn]); > image( >for i=-n upto n: > draw (0,i*in/a)--(size,i*in/b); > %withpen pencircle scaled 3/5defaultthickness; >endfor >for i=1 upto dn: > k:=(a/d[i]-1)/(a/b-1); > if known labit[i]: >string s; s:=decimal(d[i]); xs:=0; >picture p,q; q := p := depthless(s); >if i=dn: > q := depthless(s & " lpi"); > xs := width(q)-width(p); >fi >label.top(q, (k*size+1/2xs, n*in/a+1.5mm)); > fi > draw (k*size, n*in/a+1.5mm)--(k*size, k[n*in/a,n*in/b]+.5mm); > draw (k*size, -n*in/a-1.5mm)--(k*size, -k[n*in/a,n*in/b]-.5mm); >endfor > ) endgroup > enddef; > draw Moire(57.5mm)(200, 175, 150, 125, 100, 75); > % ulshiftedto (142mm, 38.5mm); > \stopreusableMPgraphic As that at least makes it an expression instead of a statement list. But also depthless() is never defined? — Taco Hoekwater E: t...@bittext.nl genderfluid (all pronouns) ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] setupexternalfigures and resoĺution
Am 01.09.22 um 12:37 schrieb juh+ntg-context--- via ntg-context: Hi Hraban, Am 01.09.22 um 10:56 schrieb Henning Hraban Ramm via ntg-context: \startluacode local function downsampler(oldname, newname, resolution) if not resolution or resolution == "" then resolution = 72 end local cmd = string.format( [[gm convert -resample %ix%i %s %s]], resolution, resolution, oldname, newname) os.execute(cmd) end -- Set the PDF and default JPEG converters to the above function. figures.converters.jpg.pdf = downsampler figures.converters.jpg.default = downsampler \stopluacode I didn’t manage to plug this into the "conversion" mechanism. Thanks a lot. With this I get 5.9MB instead of 13MB. Maybe I can skip postprocessing the pdf file with ps2pdf. From an error message I guess that this script also tries to downsample png files. Is that correct? According to the sources it should only attack JPEGs. Hraban ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] setupexternalfigures and resoĺution
Am 01.09.22 um 13:43 schrieb juh+ntg-context--- via ntg-context: Am 01.09.22 um 10:51 schrieb Henning Hraban Ramm via ntg-context: \loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }% \setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ] With the script I get strange results. I am not sure whether the resolution is correctly calculated. And I am wondering what the script is doing with png files. This one attacks all images, but it doesn’t calculate the final size correctly. Hraban ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to make a reference go to an exact point of a section on a page?
On Thu, Sep 1, 2022 at 2:37 PM amano.kenji via ntg-context wrote: > > I just created a reference to a \section with \in. > > Clicking the \in reference doesn't go to the \section, but to the page that > has the \section. > > Does ConTeXt lack the ability to go to an exact point of a numbered element > on a page? > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / > https://www.ntg.nl/mailman/listinfo/ntg-context > webpage : https://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : https://contextgarden.net > ___ I think \setupinteraction[focus=standard] is what you need. /Mikael ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] How to make a reference go to an exact point of a section on a page?
I just created a reference to a \section with \in. Clicking the \in reference doesn't go to the \section, but to the page that has the \section. Does ConTeXt lack the ability to go to an exact point of a numbered element on a page? ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] setupexternalfigures and resoĺution
Am 01.09.22 um 10:51 schrieb Henning Hraban Ramm via ntg-context: \loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }% \setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ] With the script I get strange results. I am not sure whether the resolution is correctly calculated. And I am wondering what the script is doing with png files. juh ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] setupexternalfigures and resoĺution
Hi Hraban, Am 01.09.22 um 10:56 schrieb Henning Hraban Ramm via ntg-context: \startluacode local function downsampler(oldname, newname, resolution) if not resolution or resolution == "" then resolution = 72 end local cmd = string.format( [[gm convert -resample %ix%i %s %s]], resolution, resolution, oldname, newname) os.execute(cmd) end -- Set the PDF and default JPEG converters to the above function. figures.converters.jpg.pdf = downsampler figures.converters.jpg.default = downsampler \stopluacode I didn’t manage to plug this into the "conversion" mechanism. Thanks a lot. With this I get 5.9MB instead of 13MB. Maybe I can skip postprocessing the pdf file with ps2pdf. From an error message I guess that this script also tries to downsample png files. Is that correct? juh ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] setupexternalfigures and resoĺution
Am 01.09.22 um 10:51 schrieb Henning Hraban Ramm via ntg-context: Am 01.09.22 um 10:44 schrieb juh+ntg-context--- via ntg-context: Hi, what is resolution meant to do? What am I missing? The resolution parameter is still not used by default ConTeXt, sorry. But you can use it with the attached lua file like: This works also: \startluacode local function downsampler(oldname, newname, resolution) if not resolution or resolution == "" then resolution = 72 end local cmd = string.format( [[gm convert -resample %ix%i %s %s]], resolution, resolution, oldname, newname) os.execute(cmd) end -- Set the PDF and default JPEG converters to the above function. figures.converters.jpg.pdf = downsampler figures.converters.jpg.default = downsampler \stopluacode I didn’t manage to plug this into the "conversion" mechanism. Hraban ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] setupexternalfigures and resoĺution
Am 01.09.22 um 10:44 schrieb juh+ntg-context--- via ntg-context: Hi, what is resolution meant to do? Whatever I insert as resolution, I get no change. \setupexternalfigure[location={default,local},resolution=30] \starttext \externalfigure[hacker] \stoptext What am I missing? The resolution parameter is still not used by default ConTeXt, sorry. But you can use it with the attached lua file like: \loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }% \setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ] Hraban if not modules then modules = { } end modules ['grph-downsample'] = { version = 1.100, comment = "companion to grph-inc.mkiv", author= "Peter Münster", -- adapted to LMTX by Hraban copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } assert(not figures.getinfo2) figures.getinfo2 = function(name, page) -- [ [NTG-context] Pdf info with Lua/Ctx API ] if type(name) == "string" then name = { name = name, page = page } end if name.name then local data = figures.push(name) local info = figures.identify() if info.status.status ~= 0 then figures.check() -- !Counts pages here! end figures.pop() return --data info end end local format = string.format -- figures.cachepaths.path = "cache" -- should be setup-option local function sample_down(oldname, newname, resolution) print("DOWNSAMPLE sample_down " .. oldname .. " to " .. newname) local request = figures.current().request local width = request.width local height = request.height if resolution == "" then -- or (not width and not height) then print(format("DOWNSAMPLE Nothing to do: %s, %s, %s dpi, %s x %s px", oldname, newname, resolution, width, height)) return end local TEXpt = 65536 local inch = 72.27 -- MkIV: -- local image = img.scan{filename = oldname} -- LMTX: local image = figures.getinfo(oldname,1) image = image.status.private local xy = image.xsize / image.ysize if (not width and not height) then -- no size requested? use default width width = 300 * TEXpt end if not width then height = height / TEXpt width = height * xy end if not height then width = width / TEXpt height = width / xy end width = math.floor(width) height = math.floor(height) print(format("DOWNSAMPLE image size %dx%dpx. requested %dx%d?", image.xsize, image.ysize, width, height)) local xsize = math.floor(resolution * width / inch) local ysize = math.floor(resolution * height / inch) print(format("DOWNSAMPLE size %d x %d to %d x %d", image.xsize, image.ysize, xsize, ysize)) if xsize < image.xsize or ysize < image.ysize then local s = format("gm convert -resize %dx%d -resample %dx%d %s %s", xsize, ysize, resolution, resolution, oldname, newname) print("DOWNSAMPLE Conversion: " .. s) os.execute(s) else print(format("DOWNSAMPLE Nothing to do: %s, %s, %s dpi, %d x %d px", oldname, newname, resolution, width, height)) print(format("DOWNSAMPLE xsize = %d, ysize = %d", xsize, ysize)) end end local formats = {"png", "jpg", "gif"} for _, s in ipairs(formats) do figures.converters[s] = figures.converters[s] or {} figures.converters[s]["lowres." .. s] = sample_down end ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] setupexternalfigures and resoĺution
Hi, what is resolution meant to do? Whatever I insert as resolution, I get no change. \setupexternalfigure[location={default,local},resolution=30] \starttext \externalfigure[hacker] \stoptext What am I missing? TIA juh ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] update old MP code
Hi, here’s a snippet of old Metapost code that I’d like to use in ConTeXt. I didn’t manage to update it to MetaFun – can you help me? Hraban - \setupbodyfont[plex,ss,8bp] \startreusableMPgraphic{moiree} % 1994 by Bogusław Jackowski (GUST) defaultfont := "\truefontname{Sans}"; pickup pencircle scaled 0.3bp; defaultscale := .8; linecap := butt; labeloffset := 1.5bp; defaultthickness:=.3bp; % 5 pixels at 1200 dpi % tertiarydef p ulshiftedto s = p shifted (s-ulcorner(p)) enddef; def Moire(expr size)(text densities)= save dn,a,b,k,labit,n,p,q,s,xs; n := 32; dn := 0; for i := densities: d[incr dn] := abs(i); if i>1: labit[dn]:=1; fi endfor a := min(d[1],d[dn]); b := max(d[1],d[dn]); image( for i=-n upto n: draw (0,i*in/a)--(size,i*in/b); %withpen pencircle scaled 3/5defaultthickness; endfor for i=1 upto dn: k:=(a/d[i]-1)/(a/b-1); if known labit[i]: string s; s:=decimal(d[i]); xs:=0; picture p,q; q := p := depthless(s); if i=dn: q := depthless(s & " lpi"); xs := width(q)-width(p); fi label.top(q, (k*size+1/2xs, n*in/a+1.5mm)); fi draw (k*size, n*in/a+1.5mm)--(k*size, k[n*in/a,n*in/b]+.5mm); draw (k*size, -n*in/a-1.5mm)--(k*size, -k[n*in/a,n*in/b]-.5mm); endfor ) enddef; draw Moire(57.5mm)(200, 175, 150, 125, 100, 75); % ulshiftedto (142mm, 38.5mm); \stopreusableMPgraphic \starttext \reuseMPgraphic{moiree} \stoptext - moireetest.tex Description: TeX document ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___