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 Then, \starttext \externalfigure[something] \stoptext fails. However, if I set \externalfigure[something][method=jpg] the figure loads correctly. But what is surprising is that if I set \externalfigure[something][method=pdf] then also the figure loads correctly! This means that context has the code to recognize the figure type (even without the extension), but that fails when method is not set. Setting a global \setupexternalfigures[method=pdf] does not work because method is reset to empty by \resetfiguresettings. Any ideas on how to load an external figure without a file extension and not specifying the figure type by hand? Aditya
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 -----------------------------------------------------------------
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 -----------------------------------------------------------------
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
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 -----------------------------------------------------------------
On Sat, May 26, 2012 at 4:23 PM, 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] This can be interesting http://www.garykessler.net/library/file_sigs.html
-- luigi
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).
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
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).
participants (4)
-
Aditya Mahajan
-
Hans Hagen
-
luigi scarso
-
Rogers, Michael K