* Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
[not found] <mailman.727.1550955497.1205.ntg-context@ntg.nl>
@ 2019-02-23 22:38 ` Jeong Dal
2019-02-24 8:11 ` When newsizing an external figure by " Rudolf Bahr
0 siblings, 1 reply; 11+ messages in thread
From: Jeong Dal @ 2019-02-23 22:38 UTC (permalink / raw)
To: list ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl
ntg-context@ntg.nl
[-- Attachment #1.1: Type: text/plain, Size: 677 bytes --]
Dear Rudolf,
It is working for me.
Using my figure, I got
(45126287sp,31048991sp)
(1372,944)
As Hans said, either change ~ to some path or set the directory of externalfigure.
Best regards,
Dalyoung
> 2019. 2. 24. 오전 5:58, ntg-context-request@ntg.nl 작성:
>
> I fear it doesn't work. I used the above code with a test-picture of mine
> (in .png and .jpg version) and got:
>
> (0sp,0sp)
> (0,0)
>
> Now I'm baffled what the explanation could be. Are "mill" or "cow" somehow
> specially prepared? I used:
>
> ConTeXt ver: 2018.03.16 22:20 MKIV beta fmt: 2018.3.21 and
> getfiguredimensions[~/my-test-picture.png]
>
> Rudolf
[-- Attachment #1.2: Type: text/html, Size: 9327 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure by [width=<some pt>], what will be its height in pt and viceversa?
2019-02-23 22:38 ` When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa? Jeong Dal
@ 2019-02-24 8:11 ` Rudolf Bahr
2019-02-27 8:55 ` Henning Hraban Ramm
0 siblings, 1 reply; 11+ messages in thread
From: Rudolf Bahr @ 2019-02-24 8:11 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Sun, Feb 24, 2019 at 07:38:42AM +0900, Jeong Dal wrote:
> Dear Rudolf,
>
> It is working for me.
> Using my figure, I got
> (45126287sp,31048991sp)
>
> (1372,944)
>
>
> As Hans said, either change ~ to some path or set the directory of externalfigure.
>
> Best regards,
>
> Dalyoung
Hello Dalyoung,
thank you for your message!
Yes, "~" was the reason for my failure. Its use seems to be linux specific only.
If you convert your sp-sizes into pt-sizes (1pt = 65536sp) you will get:
(45126287sp,31048991sp) = (688.5725pt,473.7700pt)
What do you think, are these pt-values ok to you? In my opinion they seem to be too
small. How are they calculated?
Cheers,
Rudolf
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure by [width=<some pt>], what will be its height in pt and viceversa?
2019-02-24 8:11 ` When newsizing an external figure by " Rudolf Bahr
@ 2019-02-27 8:55 ` Henning Hraban Ramm
2019-02-27 15:56 ` Rudolf Bahr
0 siblings, 1 reply; 11+ messages in thread
From: Henning Hraban Ramm @ 2019-02-27 8:55 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 2019-02-24 um 09:11 schrieb Rudolf Bahr <quasi@quasi.de>:
> Yes, "~" was the reason for my failure. Its use seems to be linux specific only.
No, it’s not Linux specific, but ConTeXt doesn’t expand shell variables.
Greetlings, Hraban
---
https://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure by [width=<some pt>], what will be its height in pt and viceversa?
2019-02-27 8:55 ` Henning Hraban Ramm
@ 2019-02-27 15:56 ` Rudolf Bahr
0 siblings, 0 replies; 11+ messages in thread
From: Rudolf Bahr @ 2019-02-27 15:56 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Wed, Feb 27, 2019 at 09:55:07AM +0100, Henning Hraban Ramm wrote:
> Am 2019-02-24 um 09:11 schrieb Rudolf Bahr <quasi@quasi.de>:
>
> > Yes, "~" was the reason for my failure. Its use seems to be linux specific only.
>
> No, it’s not Linux specific, but ConTeXt doesn’t expand shell variables.
>
> Greetlings, Hraban
Aha! Thank you.
Cheers, Rudolf
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
2019-02-23 11:37 ` Rudolf Bahr
@ 2019-02-23 11:48 ` Hans Hagen
0 siblings, 0 replies; 11+ messages in thread
From: Hans Hagen @ 2019-02-23 11:48 UTC (permalink / raw)
To: mailing list for ConTeXt users, Rudolf Bahr
On 2/23/2019 12:37 PM, Rudolf Bahr wrote:
> On Sat, Feb 23, 2019 at 11:56:32AM +0100, Hans Hagen wrote:
>> On 2/23/2019 11:08 AM, Rudolf Bahr wrote:
>>> On Fri, Feb 22, 2019 at 12:59:55PM +0100, Peter Münster wrote:
>>>> On Fri, Feb 22 2019, Rudolf Bahr wrote:
>>>>
>>>>> The picture sizes in px One gets by invoking for instance graphics Magick's identify
>>>>> in a lua program:
>>>>
>>>> Or just img.scan():
>>>>
>>>> \startluacode
>>>> local image = img.scan{filename = "my-image.jpg"}
>>>> logs.report("xsize", image.xsize)
>>>> logs.report("ysize", image.ysize)
>>>> \stopluacode
>>>>
>>>> --
>>>> Peter
>>>
>>> Hi Peter,
>>>
>>> thank you for pointing to img.scan{}! It's indeed shorter than to invoke Graphics Magick
>>> in Lua. Remains the conversion of image sizes into pt. There is an example in the chapter
>>> "Calculations in Lua" in "https://wiki.contextgarden.net/Image_Placement" (a work in
>>> progress). According to there it's necessary to know the resolution in order to convert
>>> image sizes from px to pt which at least I don't know. Mostly I can preset one size of
>>> a picture (say the width in pt) to be able to place it on a page and assuming
>>> x-resolution = y-resolution and keeping width-to-height ratio I calculate the missing
>>> size (here the height in pt) in Lua by
>>>
>>> picture-height-in-px
>>> asked-picture-height-in-pt = preset-picture-width-in-pt * --------------------
>>> picture-width-in-px
>>>
>>> This is simple and normally it suffices for me.
>> Better use the built-in methods:
>>
>> \starttext
>>
>> \getfiguredimensions[t:/sources/mill.png]
>>
>> (\figurewidth,\figureheight)
>>
>> (\figurexsize,\figureysize)
>>
>> \stoptext
>>
>> as it prevents opening the files multiple times. It's also more futureproof.
>>
>> Hans
>>
>
> Hi Hans,
>
> I fear it doesn't work. I used the above code with a test-picture of mine
> (in .png and .jpg version) and got:
>
> (0sp,0sp)
> (0,0)
>
> Now I'm baffled what the explanation could be. Are "mill" or "cow" somehow
> specially prepared? I used:
>
> ConTeXt ver: 2018.03.16 22:20 MKIV beta fmt: 2018.3.21 and
> getfiguredimensions[~/my-test-picture.png]
maybe the image is not found ... what if you replace the ~
--
-----------------------------------------------------------------
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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
2019-02-23 10:56 ` Hans Hagen
@ 2019-02-23 11:37 ` Rudolf Bahr
2019-02-23 11:48 ` Hans Hagen
0 siblings, 1 reply; 11+ messages in thread
From: Rudolf Bahr @ 2019-02-23 11:37 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Sat, Feb 23, 2019 at 11:56:32AM +0100, Hans Hagen wrote:
> On 2/23/2019 11:08 AM, Rudolf Bahr wrote:
> > On Fri, Feb 22, 2019 at 12:59:55PM +0100, Peter Münster wrote:
> > > On Fri, Feb 22 2019, Rudolf Bahr wrote:
> > >
> > > > The picture sizes in px One gets by invoking for instance graphics Magick's identify
> > > > in a lua program:
> > >
> > > Or just img.scan():
> > >
> > > \startluacode
> > > local image = img.scan{filename = "my-image.jpg"}
> > > logs.report("xsize", image.xsize)
> > > logs.report("ysize", image.ysize)
> > > \stopluacode
> > >
> > > --
> > > Peter
> >
> > Hi Peter,
> >
> > thank you for pointing to img.scan{}! It's indeed shorter than to invoke Graphics Magick
> > in Lua. Remains the conversion of image sizes into pt. There is an example in the chapter
> > "Calculations in Lua" in "https://wiki.contextgarden.net/Image_Placement" (a work in
> > progress). According to there it's necessary to know the resolution in order to convert
> > image sizes from px to pt which at least I don't know. Mostly I can preset one size of
> > a picture (say the width in pt) to be able to place it on a page and assuming
> > x-resolution = y-resolution and keeping width-to-height ratio I calculate the missing
> > size (here the height in pt) in Lua by
> >
> > picture-height-in-px
> > asked-picture-height-in-pt = preset-picture-width-in-pt * --------------------
> > picture-width-in-px
> >
> > This is simple and normally it suffices for me.
> Better use the built-in methods:
>
> \starttext
>
> \getfiguredimensions[t:/sources/mill.png]
>
> (\figurewidth,\figureheight)
>
> (\figurexsize,\figureysize)
>
> \stoptext
>
> as it prevents opening the files multiple times. It's also more futureproof.
>
> Hans
>
Hi Hans,
I fear it doesn't work. I used the above code with a test-picture of mine
(in .png and .jpg version) and got:
(0sp,0sp)
(0,0)
Now I'm baffled what the explanation could be. Are "mill" or "cow" somehow
specially prepared? I used:
ConTeXt ver: 2018.03.16 22:20 MKIV beta fmt: 2018.3.21 and
getfiguredimensions[~/my-test-picture.png]
Rudolf
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
2019-02-23 10:08 ` Rudolf Bahr
@ 2019-02-23 10:56 ` Hans Hagen
2019-02-23 11:37 ` Rudolf Bahr
0 siblings, 1 reply; 11+ messages in thread
From: Hans Hagen @ 2019-02-23 10:56 UTC (permalink / raw)
To: mailing list for ConTeXt users, Rudolf Bahr
On 2/23/2019 11:08 AM, Rudolf Bahr wrote:
> On Fri, Feb 22, 2019 at 12:59:55PM +0100, Peter Münster wrote:
>> On Fri, Feb 22 2019, Rudolf Bahr wrote:
>>
>>> The picture sizes in px One gets by invoking for instance graphics Magick's identify
>>> in a lua program:
>>
>> Or just img.scan():
>>
>> \startluacode
>> local image = img.scan{filename = "my-image.jpg"}
>> logs.report("xsize", image.xsize)
>> logs.report("ysize", image.ysize)
>> \stopluacode
>>
>> --
>> Peter
>
> Hi Peter,
>
> thank you for pointing to img.scan{}! It's indeed shorter than to invoke Graphics Magick
> in Lua. Remains the conversion of image sizes into pt. There is an example in the chapter
> "Calculations in Lua" in "https://wiki.contextgarden.net/Image_Placement" (a work in
> progress). According to there it's necessary to know the resolution in order to convert
> image sizes from px to pt which at least I don't know. Mostly I can preset one size of
> a picture (say the width in pt) to be able to place it on a page and assuming
> x-resolution = y-resolution and keeping width-to-height ratio I calculate the missing
> size (here the height in pt) in Lua by
>
> picture-height-in-px
> asked-picture-height-in-pt = preset-picture-width-in-pt * --------------------
> picture-width-in-px
>
> This is simple and normally it suffices for me.
Better use the built-in methods:
\starttext
\getfiguredimensions[t:/sources/mill.png]
(\figurewidth,\figureheight)
(\figurexsize,\figureysize)
\stoptext
as it prevents opening the files multiple times. It's also more futureproof.
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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
2019-02-22 11:59 ` Peter Münster
@ 2019-02-23 10:08 ` Rudolf Bahr
2019-02-23 10:56 ` Hans Hagen
0 siblings, 1 reply; 11+ messages in thread
From: Rudolf Bahr @ 2019-02-23 10:08 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Fri, Feb 22, 2019 at 12:59:55PM +0100, Peter Münster wrote:
> On Fri, Feb 22 2019, Rudolf Bahr wrote:
>
> > The picture sizes in px One gets by invoking for instance graphics Magick's identify
> > in a lua program:
>
> Or just img.scan():
>
> \startluacode
> local image = img.scan{filename = "my-image.jpg"}
> logs.report("xsize", image.xsize)
> logs.report("ysize", image.ysize)
> \stopluacode
>
> --
> Peter
Hi Peter,
thank you for pointing to img.scan{}! It's indeed shorter than to invoke Graphics Magick
in Lua. Remains the conversion of image sizes into pt. There is an example in the chapter
"Calculations in Lua" in "https://wiki.contextgarden.net/Image_Placement" (a work in
progress). According to there it's necessary to know the resolution in order to convert
image sizes from px to pt which at least I don't know. Mostly I can preset one size of
a picture (say the width in pt) to be able to place it on a page and assuming
x-resolution = y-resolution and keeping width-to-height ratio I calculate the missing
size (here the height in pt) in Lua by
picture-height-in-px
asked-picture-height-in-pt = preset-picture-width-in-pt * --------------------
picture-width-in-px
This is simple and normally it suffices for me.
Rudolf
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
2019-02-22 9:14 ` Rudolf Bahr
@ 2019-02-22 11:59 ` Peter Münster
2019-02-23 10:08 ` Rudolf Bahr
0 siblings, 1 reply; 11+ messages in thread
From: Peter Münster @ 2019-02-22 11:59 UTC (permalink / raw)
To: ntg-context
On Fri, Feb 22 2019, Rudolf Bahr wrote:
> The picture sizes in px One gets by invoking for instance graphics Magick's identify
> in a lua program:
Or just img.scan():
\startluacode
local image = img.scan{filename = "my-image.jpg"}
logs.report("xsize", image.xsize)
logs.report("ysize", image.ysize)
\stopluacode
--
Peter
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
2019-02-19 9:48 When newsizing an external figure bei " Rudolf Bahr
@ 2019-02-22 9:14 ` Rudolf Bahr
2019-02-22 11:59 ` Peter Münster
0 siblings, 1 reply; 11+ messages in thread
From: Rudolf Bahr @ 2019-02-22 9:14 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Tue, Feb 19, 2019 at 10:48:38AM +0100, Bahr Rudolf wrote:
> Hi All,
>
> from an external figure I normally know its width and height in px.
> But I don't know its exact sizes in pt. When newsizing the figure
> in a document (by the same width-to-height-ratio), I'll do that as
> some part of textwidth or textheight, in pt or mm, but not in px,
> i.e. by means of [width=<some pt>].
> Sometimes it would be interesting to know its new height in pt,
> and viceversa.
>
> Is there a variable or something else containing its new size in pt?
>
> Regards,
> Rudolf
Hi All,
up to now Nobody answered to my question, perhaps it might have been
too simple.
Indeed One could normally assume:
picture-width-in-px preset-picture-width-in-pt
-------------------- = --------------------------
picture-height-in-px asked-picture-height-in-pt
And according to Adam Riese One gets:
preset-picture-width-in-pt * picture-height-in-px
asked-picture-height-in-pt = ---------------------------------------------------
picture-width-in-px
-----------------
The picture sizes in px One gets by invoking for instance graphics Magick's identify
in a lua program:
local file = assert ( io.popen ( 'gm identify ' .. picture_name, 'r' ))
local output = file:read ( '*all' )
file:close ()
local words = {}
for w in string.gmatch ( output, "%g+" ) do
words [ #words + 1 ] = w
end
-- Width and height are found in words[3]: i.e. 5407x3544+0+0
local dims = {}
for d in string.gmatch ( words [ 3 ], "%d+" ) do
dims [ #dims + 1 ] = d
end
local px_width = dims [ 1 ]
local px_height = dims [ 2 ]
-----------------
It's a solution at least as long as your Lua supports "io.popen". There might be
shorter solutions.
Cheers, Rudolf
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
* When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
@ 2019-02-19 9:48 Rudolf Bahr
2019-02-22 9:14 ` Rudolf Bahr
0 siblings, 1 reply; 11+ messages in thread
From: Rudolf Bahr @ 2019-02-19 9:48 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi All,
from an external figure I normally know its width and height in px.
But I don't know its exact sizes in pt. When newsizing the figure
in a document (by the same width-to-height-ratio), I'll do that as
some part of textwidth or textheight, in pt or mm, but not in px,
i.e. by means of [width=<some pt>].
Sometimes it would be interesting to know its new height in pt,
and viceversa.
Is there a variable or something else containing its new size in pt?
Regards,
Rudolf
___________________________________________________________________________________
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-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-02-27 15:56 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <mailman.727.1550955497.1205.ntg-context@ntg.nl>
2019-02-23 22:38 ` When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa? Jeong Dal
2019-02-24 8:11 ` When newsizing an external figure by " Rudolf Bahr
2019-02-27 8:55 ` Henning Hraban Ramm
2019-02-27 15:56 ` Rudolf Bahr
2019-02-19 9:48 When newsizing an external figure bei " Rudolf Bahr
2019-02-22 9:14 ` Rudolf Bahr
2019-02-22 11:59 ` Peter Münster
2019-02-23 10:08 ` Rudolf Bahr
2019-02-23 10:56 ` Hans Hagen
2019-02-23 11:37 ` Rudolf Bahr
2019-02-23 11:48 ` Hans Hagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).