[NTG-context] Re: setupexternalfigures and resoĺution
This thread about downsampling external images on the fly is a really helpful feature! Thanks, Hraban for sharing the code! I was wondering if it was possible to downscale also raster images embedded in pdf/svg files loaded via \externalfigure? I found a ghostscript solution online (https://stackoverflow.com/questions/9497120/how-to-downsample-images-within-pdf-file) gs \ -o downsampled.pdf \ -sDEVICE=pdfwrite \ -dDownsampleColorImages=true \ -dDownsampleGrayImages=true \ -dDownsampleMonoImages=true \ -dColorImageResolution=72 \ -dGrayImageResolution=72 \ -dMonoImageResolution=72 \ -dColorImageDownsampleThreshold=1.0 \ -dGrayImageDownsampleThreshold=1.0 \ -dMonoImageDownsampleThreshold=1.0 \ input.pdf Now, I'm wondering how to adapt grph-downsample.lua to do this? I've tried: \setupexternalfigure[ resolution=\Resolution, conversion=lowres.pdf ] And added to grph-downsample.lua local function sample_down_pdf(oldname, newname, resolution) print("DOWNSAMPLE sample_down " .. oldname .. " to " .. newname) -- MkIV: -- local image = img.scan{filename = oldname} -- LMTX: local image = figures.getinfo(oldname,1) image = image.status.private local s = format("gs \ -o \"%s\" \ -sDEVICE=pdfwrite \ -dDownsampleColorImages=true \ -dDownsampleGrayImages=true \ -dDownsampleMonoImages=true \ -dColorImageResolution=%s \ -dGrayImageResolution=%s \ -dMonoImageResolution=%s \ -dColorImageDownsampleThreshold=1.0 \ -dGrayImageDownsampleThreshold=1.0 \ -dMonoImageDownsampleThreshold=1.0 \ \"%s\"", oldname, resolution, resolution, resolution, newname) print("DOWNSAMPLE Conversion: " .. s) os.execute(s) end figures.converters["pdf"]["lowres." .. "pdf"] = sample_down_pdf But I must be missing something as the code doesn't seem to be called. Any suggestions? Thanks! Ben ___ 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] Cron /var/www/aanhet.net/context/bin/cron/context-mirror
receiving incremental file list ./ ctan.lsr document-2.htm download-1.htm download-2.htm logo-ade.png logo-cts.png logo-pod.png rss.xml show-fil.pdf context/latest/ context/latest/cont-lmt.zip context/latest/cont-mpd.zip context/latest/cont-ppc.zip context/latest/cont-sci.zip context/latest/cont-tmf.zip context/latest/cont-tst.7z context/latest/cont-tst.tar.xz context/latest/cont-tst.zip sent 175,476 bytes received 39,200,805 bytes 2,715,605.59 bytes/sec total size is 562,234,713 speedup is 14.28 Running archiver: New dir: /var/www/aanhet.net/context//htdocs/archives/context-2023-07-28.21 233581279 /var/www/aanhet.net/context//htdocs/archives/context-2023-07-28.21/latest 126745317 /var/www/aanhet.net/context//htdocs/archives/context-2023-07-28.21/current 360330692 /var/www/aanhet.net/context//htdocs/archives/context-2023-07-28.21 360330692 total ___ 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] Re: Par Builder Tests
Thanks Hraban, didn't think of that so will give it a try. Best Wishes Keith On Fri, 28 Jul 2023, 17:28 Henning Hraban Ramm, wrote: > Am 28.07.23 um 17:04 schrieb Keith McKay: > > I played around with the setups for the align:pass:test4 code below, as > > Hans suggested, and it was changing the \tolerance value which made the > > difference. Increasing the \tolerance value to 1000 eliminated all > > overfull hboxes but still left 79 underfull hboxes. I continued to > > increase the \tolerance value up to 6600 and was left with two overfull > > hboxes. One with a badness of 6641 (warAndPeace1.png) and one with a > > badness of 1097 (warAndPeace2.png). Above the \tolerance of 6600 only > > warAndPeace2.png was left with a badness of 1097. Both of these > > underfull hboxes were at the beginning of a paragraph - "To his Honor" > > in the first png and "Well, you see," in the second png. I not sure a > > reader would spot the second png badness but the first is noticeable to > > my eyes. > > Hi Keith, > since both cases are caused by names with accents, did you try to add > hyphenation exceptions for those? Such cases are probably not covered by > English hyphentation rules. > > 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 > > ___ > ___ 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] Re: Par Builder Tests
Am 28.07.23 um 17:04 schrieb Keith McKay: I played around with the setups for the align:pass:test4 code below, as Hans suggested, and it was changing the \tolerance value which made the difference. Increasing the \tolerance value to 1000 eliminated all overfull hboxes but still left 79 underfull hboxes. I continued to increase the \tolerance value up to 6600 and was left with two overfull hboxes. One with a badness of 6641 (warAndPeace1.png) and one with a badness of 1097 (warAndPeace2.png). Above the \tolerance of 6600 only warAndPeace2.png was left with a badness of 1097. Both of these underfull hboxes were at the beginning of a paragraph - "To his Honor" in the first png and "Well, you see," in the second png. I not sure a reader would spot the second png badness but the first is noticeable to my eyes. Hi Keith, since both cases are caused by names with accents, did you try to add hyphenation exceptions for those? Such cases are probably not covered by English hyphentation rules. 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 ___
[NTG-context] Re: Par Builder Tests
Hi all! Using the example below I have completed a test using a larger book. This time I downloaded War and Peace from the Gutenberg Project and extracted the individual xhtml files for Context. I played around with the setups for the align:pass:test4 code below, as Hans suggested, and it was changing the \tolerance value which made the difference. Increasing the \tolerance value to 1000 eliminated all overfull hboxes but still left 79 underfull hboxes. I continued to increase the \tolerance value up to 6600 and was left with two overfull hboxes. One with a badness of 6641 (warAndPeace1.png) and one with a badness of 1097 (warAndPeace2.png). Above the \tolerance of 6600 only warAndPeace2.png was left with a badness of 1097. Both of these underfull hboxes were at the beginning of a paragraph - "To his Honor" in the first png and "Well, you see," in the second png. I not sure a reader would spot the second png badness but the first is noticeable to my eyes. I'm very pleased how the book has turned out, all 1668 pages of it as an approximately 13cm by 20cm book. The pdf is 4MB and each run in ConTeXt takes about 10 seconds on my M1 mac mini. I'm interested in seeing how \setupalignpass develops and learning more of how to use it. Best Wishes Keith McKay On 21/07/2023 17:33, Keith McKay wrote: Thanks Hans! I'll have a play and keep an eye on updates Best Wishes Keith On 21/07/2023 17:10, Hans Hagen via ntg-context wrote: Hi Keith, Here an example that Mikael made for such a book: \showframe % let's very strict \startsetups [*default] \directsetup{*reset} \frozen\widowpenalty 1 \frozen\clubpenalty 1 \frozen\displaywidowpenalty 1 \frozen\brokenpenalty 0 % \defaultbrokenpenalty \stopsetups % we enable the use of expansion (this feature might become preset % because we now delay setting the vectors anyway so less overhead) \definefontfeature [default] [default] [expansion=quality, protrusion=quality, itlc=yes] % vertical expansion \setuplayout [vz=2] % for which we need: % \setupalign[hanging,depth,stretch,granular] \setupalign[depth,stretch,granular] % here are the passes: \startsetups align:pass:test4 \pretolerance 100 \tolerance 200 \parpasses 4 classes \indecentparpassclasses threshold 0.025pt adjustspacing 3 adjustspacingstep 1 adjustspacingshrink 5 adjustspacingstretch 10 next classes \indecentparpassclasses threshold 0.025pt adjustspacing 3 adjustspacingstep 1 adjustspacingshrink 10 adjustspacingstretch 20 next classes \indecentparpassclasses threshold 0.025pt adjustspacing 3 adjustspacingstep 1 adjustspacingshrink 25 adjustspacingstretch 50 next classes \indecentparpassclasses threshold 0.025pt adjustspacing 3 adjustspacingstep 1 adjustspacingshrink 50 adjustspacingstretch 100 \relax \stopsetups \setupalignpass[test4] \starttext ... \stoptext (work in progress so keep an eye on updates) Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ 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 ___ ___ 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 ___