From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/103373 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Peter_M=C3=BCnster?= Newsgroups: gmane.comp.tex.context Subject: t-downsample.lua Date: Sun, 17 Feb 2019 11:32:46 +0100 Message-ID: <87k1hyvh69.fsf@a16n.net> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="175785"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Sun Feb 17 11:33:14 2019 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gvJl2-000jYT-U5 for gctc-ntg-context-518@m.gmane.org; Sun, 17 Feb 2019 11:33:12 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id E637CEDD97; Sun, 17 Feb 2019 11:32:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zg-tr6QtsMc6; Sun, 17 Feb 2019 11:32:50 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3730DEDDB5; Sun, 17 Feb 2019 11:32:50 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id D24D6EDD8F for ; Sun, 17 Feb 2019 11:32:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S6t22pWsDxn7 for ; Sun, 17 Feb 2019 11:32:48 +0100 (CET) Original-Received: from smtp4-g21.free.fr (smtp4-g21.free.fr [212.27.42.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 41D0FEDDB5 for ; Sun, 17 Feb 2019 11:32:48 +0100 (CET) Original-Received: from ws.micropit.net (unknown [86.214.56.165]) (Authenticated sender: pandv) by smtp4-g21.free.fr (Postfix) with ESMTPSA id E672D19F58D for ; Sun, 17 Feb 2019 11:32:46 +0100 (CET) Original-Received: by ws.micropit.net (Postfix, from userid 1000) id 964E01640CE9; Sun, 17 Feb 2019 11:32:46 +0100 (CET) Mail-Followup-To: ntg-context@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:103373 Archived-At: --=-=-= Content-Type: text/plain Hi, Please find attached a new version of the module, with some ideas from Marco. Later, I'll upload it to modules.contextgarden.net. Here a usage example: \usemodule[downsample] \setupexternalfigures[ location=default, % find hacker.jpg and mill.png cache=/tmp, % where to put the low resolution images resolution=50, % resolution in DPI conversion=downsample.pdf] % use this module \starttext \externalfigure[hacker][width=0.4\textwidth] \setupexternalfigures[resolution=20] \externalfigure[mill][width=4in, height=3in] \setupexternalfigures[resolution=200] \externalfigure[mill][width=4in, height=3in] \stoptext Hans, it would be nice, to apply this patch, to trigger new conversion, when figure dimensions change: --- grph-inc.lua~ 2019-02-14 17:04:12.000000000 +0100 +++ grph-inc.lua 2019-02-17 08:45:38.129971581 +0100 @@ -864,6 +864,14 @@ newbase = prefix .. newbase end local hash = "" + local width = figures.current().request.width + local height = figures.current().request.height + if width then + hash = hash .. "[w:" .. width .. "]" + end + if height then + hash = hash .. "[h:" .. height .. "]" + end if resolution then hash = hash .. "[r:" .. resolution .. "]" end TIA, -- Peter --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=t-downsample.lua Content-Transfer-Encoding: base64 aWYgbm90IG1vZHVsZXMgdGhlbiBtb2R1bGVzID0geyB9IGVuZCBtb2R1bGVzIFsndC1kb3duc2Ft cGxlJ10gPSB7CiAgdmVyc2lvbiAgID0gMS4wMDIsCiAgY29tbWVudCAgID0gImNvbXBhbmlvbiB0 byBncnBoLWluYy5ta2l2IiwKICBhdXRob3IgICAgPSAiUGV0ZXIgTcO8bnN0ZXIiLAogIGNvcHly aWdodCA9ICJQUkFHTUEgQURFIC8gQ29uVGVYdCBEZXZlbG9wbWVudCBUZWFtIiwKICBsaWNlbnNl ICAgPSAic2VlIGNvbnRleHQgcmVsYXRlZCByZWFkbWUgZmlsZXMiCn0KCmxvY2FsIG15c2VsZiA9 ICJkb3duc2FtcGxlIgpsb2NhbCBmb3JtYXQgPSBzdHJpbmcuZm9ybWF0CmxvY2FsIHJvdW5kICA9 IG1hdGgucm91bmQKbG9jYWwgcmVwb3J0ID0gbG9ncy5yZXBvcnQKCmxvY2FsIGZ1bmN0aW9uIHNh bXBsZV9kb3duKG9sZG5hbWUsIG5ld25hbWUsIHJlc29sdXRpb24pCiAgICBsb2NhbCByZXF1ZXN0 ID0gZmlndXJlcy5jdXJyZW50KCkucmVxdWVzdAogICAgbG9jYWwgd2lkdGggICA9IHJlcXVlc3Qu d2lkdGgKICAgIGxvY2FsIGhlaWdodCAgPSByZXF1ZXN0LmhlaWdodAogICAgaWYgcmVzb2x1dGlv biA9PSAiIiBvciAobm90IHdpZHRoIGFuZCBub3QgaGVpZ2h0KSB0aGVuCiAgICAgICAgcmVwb3J0 KG15c2VsZiwgZm9ybWF0KCJub3RoaW5nIHRvIGRvOiAlcywgJXMsICVzIiwKICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgb2xkbmFtZSwgbmV3bmFtZSwgcmVzb2x1dGlvbikpCiAgICAgICAg ZmlsZS5jb3B5KG9sZG5hbWUsIG5ld25hbWUpCiAgICAgICAgcmV0dXJuCiAgICBlbmQKICAgIGxv Y2FsIGluY2ggID0gNzIuMjcgKiA2NTUzNgogICAgbG9jYWwgaW1hZ2UgPSBpbWcuc2NhbntmaWxl bmFtZSA9IG9sZG5hbWV9CiAgICBsb2NhbCB4eSAgICA9IGltYWdlLnhzaXplIC8gaW1hZ2UueXNp emUKICAgIGlmIG5vdCB3aWR0aCB0aGVuCiAgICAgICAgd2lkdGggPSBoZWlnaHQgKiB4eQogICAg ZW5kCiAgICBpZiBub3QgaGVpZ2h0IHRoZW4KICAgICAgICBoZWlnaHQgPSB3aWR0aCAvIHh5CiAg ICBlbmQKICAgIGxvY2FsIHhzaXplID0gcm91bmQocmVzb2x1dGlvbiAqIHdpZHRoICAvIGluY2gp CiAgICBsb2NhbCB5c2l6ZSA9IHJvdW5kKHJlc29sdXRpb24gKiBoZWlnaHQgLyBpbmNoKQogICAg aWYgeHNpemUgPCBpbWFnZS54c2l6ZSBvciB5c2l6ZSA8IGltYWdlLnlzaXplIHRoZW4KICAgICAg ICBsb2NhbCBzID0gZm9ybWF0KCJnbSBjb252ZXJ0IC1zdHJpcCAtcmVzaXplICVkeCVkICVzICVz IiwKICAgICAgICAgICAgICAgICAgICAgICAgIHhzaXplLCB5c2l6ZSwgb2xkbmFtZSwgbmV3bmFt ZSkKICAgICAgICByZXBvcnQoImRvd25zYW1wbGUiLCBzKQogICAgICAgIG9zLmV4ZWN1dGUocykK ICAgIGVsc2UKICAgICAgICByZXBvcnQobXlzZWxmLCBmb3JtYXQoIm5vdGhpbmcgdG8gZG86ICVz LCAlcywgJXMiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbGRuYW1lLCBuZXduYW1l LCByZXNvbHV0aW9uKSkKICAgICAgICByZXBvcnQobXlzZWxmLCBmb3JtYXQoInhzaXplID0gJWQs IHlzaXplID0gJWQiLCB4c2l6ZSwgeXNpemUpKQogICAgICAgIGZpbGUuY29weShvbGRuYW1lLCBu ZXduYW1lKQogICAgZW5kCmVuZAoKbG9jYWwgZm9ybWF0cyA9IHsicG5nIiwgImpwZyIsICJnaWYi fQoKZm9yIF8sIHMgaW4gaXBhaXJzKGZvcm1hdHMpIGRvCiAgICBmaWd1cmVzLmNvbnZlcnRlcnNb c10gPSBmaWd1cmVzLmNvbnZlcnRlcnNbc10gb3Ige30KICAgIGZpZ3VyZXMuY29udmVydGVyc1tz XVsiZG93bnNhbXBsZS5wZGYiXSA9IHNhbXBsZV9kb3duCiAgICAtLSB3aXRob3V0IHRoZSAiLnBk ZiIsIENvblRlWHQgd29uJ3QgZmluZCB0aGUgY29udmVydGVkIGltYWdlLi4uCmVuZAo= --=-=-= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --=-=-=--