Dear list, using mptopdf externalfigure "nue-logo-1.jpg" scaled 10; results in a figure that doesn't retain the original image ratio. The hints given on http://wiki.contextgarden.net/Using_Graphics would be what I want, but don't work in metapost?! Any help would be appreciated Jan-Mark
Hello Jan-Mark,
using mptopdf
externalfigure "nue-logo-1.jpg" scaled 10;
results in a figure that doesn't retain the original image ratio.
[...] I don't think it is possible. As far as I can see, the externalfigure command just includes a reference to the figure and metapost never touches (reads) the picture, only the next step (mptopdf) does. So metapost has no idea of the image attributes. Patrick (Standard disclaimer: usually, when I write something like this, Hans posts a followup with some yet unknown tricks.) -- ConTeXt wiki: http://contextgarden.net texshow-web: http://texshow.contextgarden.net List archive: http://archive.contextgarden.net
Patrick Gundlach wrote:
Hello Jan-Mark,
using mptopdf
externalfigure "nue-logo-1.jpg" scaled 10;
results in a figure that doesn't retain the original image ratio.
[...]
I don't think it is possible. As far as I can see, the externalfigure command just includes a reference to the figure and metapost never touches (reads) the picture, only the next step (mptopdf) does. So metapost has no idea of the image attributes.
Patrick
If you do not specify BOTH width and height of the image the pdftex have to read image SIZE from the image file. Metafun's externalfigure is very trickery macro. Image can't be loaded by MP. Instead of that MP writes only MP special information (like TeX \special) with several parameters. This info is read by ConTeXt when including MP graphic. It inserts image file and does image transformations. So I thing the case should work as expected. Could you send complete-and-minimal example? Vit Zyka -- Vít Zýka --- http://typokvitek.com Automatic document typesetting Automaticka sazba dokumentu -- --
[...]
So I thing the case should work as expected. Could you send complete-and-minimal example?
\starttext \startMPcode externalfigure "hacker.jpg" scaled 300; \stopMPcode \stoptext where hacker.jpg is from the official samples. P. -- ConTeXt wiki: http://contextgarden.net texshow-web: http://texshow.contextgarden.net List archive: http://archive.contextgarden.net
Patrick Gundlach wrote:
[...]
So I thing the case should work as expected. Could you send complete-and-minimal example?
\starttext \startMPcode externalfigure "hacker.jpg" scaled 300; \stopMPcode \stoptext
where hacker.jpg is from the official samples.
its possible to use the natural size, but i found out that the code that i use for that is not in the distribution (will be in the next zip) This will create a dimensions file mpfigs.mp: \startmode[*first] \executesystemcommand{texexec --fig=d *.jpg} \stopmode \starttext \startMPcode input mpfigs.mp ; naturalfigure("hacker.jpg") ; \stopMPcode \stoptext Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
So I thing the case should work as expected. Could you send complete-and-minimal example?
\starttext \startMPcode externalfigure "hacker.jpg" scaled 300; \stopMPcode \stoptext
It seems to me the behaviour is perhaps not intuitive but correct. I try to explain: Imagine externalfigure without scaling: externalfigure "hacker.jpg"; What we will obtain? One can imagine the image in its natural size. That is not the case. We obtain the image of the size 1pt x 1pt. I thing there are two reasons for that: 1) Analogy. Imagine this example: draw origin--(1,0)--(1,1)--(0,1)--cycle; it is exactly the same as draw origin--(1pt,0)--(1pt,1pt)--(0,1pt)--cycle; and it is abbreviated to draw unitsquare; and im most cases it is used with scaling draw unitsquare xscaled 2cm yscaled 1cm; since scaled X = xscaled X yscaled X then unitsquare scaled 2cm is still square. If you do not specify the unit, the pt is deduced. So there is an analogy: "unitfigure" 1pt x 1pt = externalfigure "file" 2) Technician. The scaling dimensions are calculated by TeX engine. It is done by tricks in pt units, so image 1pt x 1pt simplifies the calculations. If you want to use a bitmap in ConTeXt MP environment in its natural size, I suggest to precalculate (according to Hans macro \MPfigure) its dimmensions: % ------------------------------------ \def\getMPfiguresize#1{% \getfiguredimensionsonly[#1]% \freezedimenmacro\naturalfigurewidth \freezedimenmacro\naturalfigureheight } \def\naturalMPfigure#1{% externalfigure "#1" xscaled \naturalfigurewidth\space yscaled \naturalfigureheight\space } \starttext \getMPfiguresize{hacker.jpg} \startMPcode \naturalMPfigure{hacker.jpg} ; % space in front of ; is important!! \stopMPcode \startMPcode \naturalMPfigure{hacker.jpg} scaled 2 slanted .3; \stopMPcode \stoptext %------------------------- Vit Zyka -- Vít Zýka --- http://typokvitek.com Automatic document typesetting Automaticka sazba dokumentu -- --
Hi all, there is probably somewhere a space in some macro called inside \inmargin. See example: \starttext \setbox0\hbox{\inmargin{XX}} \showbox0 A\box0 B \stoptext and a part of log with \showbox0: \hbox(10.41603+4.05064)x3.91663 .\glue 3.91663 plus 1.95831 minus 1.30554 .\hbox(10.41603+4.05064)x0.0 ... The first glue inside hbox seems to be product of \inmargin. Does somebody know where the space is? I did not dig into sources yet, have a nice day and thanks, Martin
Hello Vit, hello list, thanks for the suggestions, they are working fine. As I can recognize its a good idea to embed my metapost code in a context file. Best regards Jan-Mark --
Martin � wrote:
Hi all,
there is probably somewhere a space in some macro called inside \inmargin. See example:
\starttext
\setbox0\hbox{\inmargin{XX}}
\showbox0
A\box0 B
\stoptext
and a part of log with \showbox0:
\hbox(10.41603+4.05064)x3.91663 .\glue 3.91663 plus 1.95831 minus 1.30554 .\hbox(10.41603+4.05064)x0.0 ...
The first glue inside hbox seems to be product of \inmargin. Does somebody know where the space is? I did not dig into sources yet,
have a nice day and thanks,
a simpler way to test this is: \ruledhbox{\inmargin{XX}} on my machine it works ok, do you use the alpha release? (That one has a new implementation of marginal things; definable and configurable) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (5)
-
Hans Hagen
-
Jan-Mark Batke
-
Martin Kolar�k
-
Patrick Gundlach
-
Vit Zyka