Re: [NTG-context] Use figures without file extension

2012-05-27 Thread Rogers, Michael K
On May 26, 2012, at 10:49 PM, Aditya Mahajan wrote:
using the inbuilt library is definely simpler!

Yes, but as you said earlier, you'll still have to do something about GIFs.  It 
would be nice if luatex had at worst a non-fatal error on scanning a 
non-supported file.

Michael




This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Hans Hagen

On 26-5-2012 04:08, Aditya Mahajan wrote:

\starttext
 \externalfigure[something]
 \stoptext


weird ... here it works ... can you runt with tracing?

\enabletrackers[graphics.locating]

\starttext
\externalfigure[cow]
\stoptext

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Hans Hagen

On 26-5-2012 04:08, Aditya Mahajan wrote:

Currently, ConTeXt only recognizes the type of figure from the file
extension. If a filename does not have an extension, \externalfigure fails.

For example:

$ cp `luatools hacker.jpg` something


ah .. i see, no extension .. too tricky to support that as they we'd 
need to run an identify on the image which is probably not what we want


i've made a simple 'identify' but am yet unsure how to use that in the 
current lookup strategy (as i want to avoid too much overhead ... using 
images without suffix is bad anyway)


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Aditya Mahajan

On Sat, 26 May 2012, Hans Hagen wrote:


On 26-5-2012 04:08, Aditya Mahajan wrote:

Currently, ConTeXt only recognizes the type of figure from the file
extension. If a filename does not have an extension, \externalfigure fails.

For example:

$ cp `luatools hacker.jpg` something


ah .. i see, no extension .. too tricky to support that as they we'd need to 
run an identify on the image which is probably not what we want


However adding `method=jpeg` works, even if the image is not a jpeg!

i've made a simple 'identify' but am yet unsure how to use that in the 
current lookup strategy (as i want to avoid too much overhead ... using 
images without suffix is bad anyway)


I am using a script to typeset rss feed to a pdf for reading on kindle. 
Some blog engines (e.g. typepad) do not set an extension for the image. As 
such, I cannot control the input. For the moment, I am using a workaround:


\let\normalexternalfigure\externalfigure
\unexpanded\def\externalfigure
{\dodoubleargument\rssfeed_externalfigure}

\def\rssfeed_externalfigure[#1][#2]%
{\normalexternalfigure[#1][\c!scale=2000, \c!method=JPEG, #2]}}

Notice the method=JPEG.

But, I think that I'll need to wrap a custom wrapper anyways, and some 
pages contain gif images which cause luatex to crash.


Aditya
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Hans Hagen

On 26-5-2012 16:04, Aditya Mahajan wrote:

On Sat, 26 May 2012, Hans Hagen wrote:


On 26-5-2012 04:08, Aditya Mahajan wrote:

Currently, ConTeXt only recognizes the type of figure from the file
extension. If a filename does not have an extension, \externalfigure
fails.

For example:

$ cp `luatools hacker.jpg` something


ah .. i see, no extension .. too tricky to support that as they we'd
need to run an identify on the image which is probably not what we want


However adding `method=jpeg` works, even if the image is not a jpeg!


i've made a simple 'identify' but am yet unsure how to use that in the
current lookup strategy (as i want to avoid too much overhead ...
using images without suffix is bad anyway)


I am using a script to typeset rss feed to a pdf for reading on kindle.
Some blog engines (e.g. typepad) do not set an extension for the image.
As such, I cannot control the input. For the moment, I am using a
workaround:

\let\normalexternalfigure\externalfigure
\unexpanded\def\externalfigure
{\dodoubleargument\rssfeed_externalfigure}

\def\rssfeed_externalfigure[#1][#2]%
{\normalexternalfigure[#1][\c!scale=2000, \c!method=JPEG, #2]}}

Notice the method=JPEG.

But, I think that I'll need to wrap a custom wrapper anyways, and some
pages contain gif images which cause luatex to crash.


I'll add a virtual type 'auto':

\externalfigure[yourname.auto]



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread luigi scarso
On Sat, May 26, 2012 at 4:23 PM, Hans Hagen pra...@wxs.nl wrote:
 On 26-5-2012 16:04, Aditya Mahajan wrote:

 On Sat, 26 May 2012, Hans Hagen wrote:

 On 26-5-2012 04:08, Aditya Mahajan wrote:

 Currently, ConTeXt only recognizes the type of figure from the file
 extension. If a filename does not have an extension, \externalfigure
 fails.

 For example:

 $ cp `luatools hacker.jpg` something


 ah .. i see, no extension .. too tricky to support that as they we'd
 need to run an identify on the image which is probably not what we want


 However adding `method=jpeg` works, even if the image is not a jpeg!

 i've made a simple 'identify' but am yet unsure how to use that in the
 current lookup strategy (as i want to avoid too much overhead ...
 using images without suffix is bad anyway)


 I am using a script to typeset rss feed to a pdf for reading on kindle.
 Some blog engines (e.g. typepad) do not set an extension for the image.
 As such, I cannot control the input. For the moment, I am using a
 workaround:

 \let\normalexternalfigure\externalfigure
 \unexpanded\def\externalfigure
 {\dodoubleargument\rssfeed_externalfigure}

 \def\rssfeed_externalfigure[#1][#2]%
 {\normalexternalfigure[#1][\c!scale=2000, \c!method=JPEG, #2]}}

 Notice the method=JPEG.

 But, I think that I'll need to wrap a custom wrapper anyways, and some
 pages contain gif images which cause luatex to crash.


 I'll add a virtual type 'auto':

 \externalfigure[yourname.auto]
This can be interesting
http://www.garykessler.net/library/file_sigs.html

-- 
luigi
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Rogers, Michael K
I don't know if this helps but the following tells what the type of the image 
file is.  (In my case I copied a jpg to img1 and a png to img2, without 
extensions of course.)

\startluacode
userdata = userdata or { }
function userdata.mytype(s)
context(img.scan({filename=s}).imagetype)
end
\stopluacode
\starttext
img1 is \ctxlua{userdata.mytype(img1)}\par
img2 is \ctxlua{userdata.mytype(img2)}
\stoptext

Michael



This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Aditya Mahajan

On Sun, 27 May 2012, Rogers, Michael K wrote:

I don't know if this helps but the following tells what the type of the 
image file is.  (In my case I copied a jpg to img1 and a png to img2, 
without extensions of course.)


Thanks.

Hans implemented a version of unix file command for checking the type of 
images, but using the inbuilt library is definely simpler!



\startluacode
userdata = userdata or { }
function userdata.mytype(s)
   context(img.scan({filename=s}).imagetype)
end
\stopluacode


@Hans, btw I also noticed that \locfilename does not work for files 
without extension. Create a file one in the current directory and then 
run:


\message{\locfilename{one}}
\end

Aditya

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___