From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/87184 Path: news.gmane.org!not-for-mail From: Otared Kavian Newsgroups: gmane.comp.tex.context Subject: Re: resize and center and clip image Date: Thu, 1 May 2014 16:59:50 +0200 Message-ID: <7BE13927-B54E-4FC6-8C9E-2669D51CC6F2@gmail.com> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1398956420 14462 80.91.229.3 (1 May 2014 15:00:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 May 2014 15:00:20 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu May 01 17:00:16 2014 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WfsT8-00042B-3d for gctc-ntg-context-518@m.gmane.org; Thu, 01 May 2014 17:00:14 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id AD46010264 for ; Thu, 1 May 2014 17:00:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7tVEXZ22wtgq for ; Thu, 1 May 2014 17:00:13 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 6D8651025E for ; Thu, 1 May 2014 17:00:10 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 40C5B101E9 for ; Thu, 1 May 2014 17:00:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yKzH7rgIkODZ for ; Thu, 1 May 2014 17:00:04 +0200 (CEST) Original-Received: from filter3-ams.mf.surf.net (filter3-ams.mf.surf.net [192.87.102.71]) by balder.ntg.nl (Postfix) with ESMTP id 02795101E1 for ; Thu, 1 May 2014 16:59:55 +0200 (CEST) Original-Received: from mail-wi0-x22b.google.com (mail-wi0-x22b.google.com [IPv6:2a00:1450:400c:c05::22b]) by filter3-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id s41Exsp0013958 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Thu, 1 May 2014 16:59:55 +0200 Original-Received: by mail-wi0-f171.google.com with SMTP id hm4so871718wib.4 for ; Thu, 01 May 2014 07:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=fTz6dFaaqlwZR3DxTO6h6YkvWy3ObMctid3lOMMSFeM=; b=eY84ARt+E75sGXLwugcQ+w1XUeTyuf1pVFN5AKsIc4GgxL3xS42083FmbpzSfkDdsd vl9dOg1vsbQYXsGSNf2KAKETpmrtoh3GfJXRumvCcXFIr6MbIY1aL5YWuXmRUfhjmUJZ FEc95y+1m1pPCZsulkue72VxMcWxXfM8rXASnfsSk7ib+rEeplmkoaX5ON9Vq+RmsOsL pnN07+J9TIjwa9A+PmMvwYixrfWg8o9pN1urI3+D0NHQswqTwqeMAjhPspICFH1lzOEX /AMbt99MI2Quf09sM0PbWW26ImSgRxKnHGrzz7bKF5/hCF9JgixdXFMvfvBbIpVQxT7E uXUw== X-Received: by 10.180.212.107 with SMTP id nj11mr2591866wic.40.1398956394711; Thu, 01 May 2014 07:59:54 -0700 (PDT) Original-Received: from [192.168.0.100] (lns-bzn-35-82-250-199-2.adsl.proxad.net. [82.250.199.2]) by mx.google.com with ESMTPSA id bq12sm1594645wib.0.2014.05.01.07.59.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 07:59:53 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.1874) X-Bayes-Prob: 0.0001 (Score 0, tokens from: ntg-context@ntg.nl, base:default, @@RPTN) X-CanIt-Geo: ip=2a00:1450:400c:c05::22b; country=IE X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 03LUCXTPL - bde9a629b453 - 20140501 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 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-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:87184 Archived-At: Hi Mikael, Out of curiosity I tried to typeset your example (after adding the usual \s= tarttext, \stoptext), but using = ConTeXt ver: 2014.04.28 23:24 MKIV beta fmt: 2014.4.29 int: english/eng= lish = I obtained a TeX error: tex error > error on line 13 in file /Users/kavian/Context/essais/mki= i/figures/resize-and-center.tex: ! Undefined control sequence \startexternalfigurecollection ...igurecollection = {#1}\settrue \c_grph_incl= u... l.13 \clip[width=3D8cm,height=3D7cm] {% 3 \startexternalfigurecollection[k.jpg] 4 \useexternalfigure[k.jpg][k.jpg] 5 \stopexternalfigurecollection I did not understand what is the =AB Undefined control sequence =BB, since = I think \clip is a known control sequence. Best regards: OK On 1 mai 2014, at 15:38, Mikael P. Sundqvist wrote: > OK, sorry for the noise. I think I have the solution: > = > \startexternalfigurecollection[k.jpg] > \useexternalfigure[k.jpg][k.jpg] > \stopexternalfigurecollection > = > = > \externalfigurecollectionminwidth{k.jpg} > \externalfigurecollectionmaxheight{k.jpg} > = > \clip[width=3D8cm,height=3D7cm]{% > \framed[width=3D8cm,height=3D7cm,align=3D{middle,lohi},offset=3Doverlay]{% > \dimen0=3D\externalfigurecollectionminwidth{k.jpg} > \dimen2=3D\externalfigurecollectionmaxheight{k.jpg} > \dimen4=3D8cm > \dimen6=3D7cm > \startluacode > if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then > local skalning =3D > -0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6]) > context("\\vskip%ssp", skalning) > context.externalfigure({"k.jpg"},{width=3D"8cm"}) > context.sprint("foo") > else > local skalning =3D > -0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4]) > context("\\hskip%ssp", skalning) > context.externalfigure({"k.jpg"},{height=3D"7cm"}) > context.sprint("bar") > end > \stopluacode > }} > = > If there are any bad side effects of this or simplifications, please > do not hesitate to tell me :) > = > /Mikael > = > On Thu, May 1, 2014 at 1:50 PM, Mikael P. Sundqvist wr= ote: >> Hi! >> = >> Assume that I want to fill in the text area with images, and I want to >> clip and scale them according to these rules: >> = >> 1) If the image is "too wide" (in sense of proportions), then scale it >> so that the height fits the text area height, center it, and clip it >> to the text area. (See the attached image, on top, where the blue area >> is supposed to show the text area and the red rectangle the image.) >> = >> 2) If the image is "too high" (in sense of proportions), then scale it >> so that the width fits the text area width, center it, and clip it to >> the text area. (See the attached image, on bottom.) >> = >> The background why I want to do this is that I'm making a small >> template for presentations, and I'd like the users to insert images as >> background without really having to think about if their proportions >> fit or not. >> = >> Best regards, Mikael > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to= the Wiki! > = > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > _________________________________________________________________________= __________ ___________________________________________________________________________= ________ If your question is of interest to others as well, please add an entry to t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________