ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Use figures without file extension
@ 2012-05-26  2:08 Aditya Mahajan
  2012-05-26  9:28 ` Hans Hagen
  2012-05-26 13:39 ` Hans Hagen
  0 siblings, 2 replies; 9+ messages in thread
From: Aditya Mahajan @ 2012-05-26  2:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use figures without file extension
  2012-05-26  2:08 Use figures without file extension Aditya Mahajan
@ 2012-05-26  9:28 ` Hans Hagen
  2012-05-26 13:39 ` Hans Hagen
  1 sibling, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2012-05-26  9:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use figures without file extension
  2012-05-26  2:08 Use figures without file extension Aditya Mahajan
  2012-05-26  9:28 ` Hans Hagen
@ 2012-05-26 13:39 ` Hans Hagen
  2012-05-26 14:04   ` Aditya Mahajan
  1 sibling, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2012-05-26 13:39 UTC (permalink / raw)
  To: Aditya Mahajan, mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use figures without file extension
  2012-05-26 13:39 ` Hans Hagen
@ 2012-05-26 14:04   ` Aditya Mahajan
  2012-05-26 14:23     ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Aditya Mahajan @ 2012-05-26 14:04 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use figures without file extension
  2012-05-26 14:04   ` Aditya Mahajan
@ 2012-05-26 14:23     ` Hans Hagen
  2012-05-26 14:26       ` luigi scarso
  0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2012-05-26 14:23 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use figures without file extension
  2012-05-26 14:23     ` Hans Hagen
@ 2012-05-26 14:26       ` luigi scarso
  2012-05-27  1:43         ` Rogers, Michael K
  0 siblings, 1 reply; 9+ messages in thread
From: luigi scarso @ 2012-05-26 14:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sat, May 26, 2012 at 4:23 PM, Hans Hagen <pragma@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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use figures without file extension
  2012-05-26 14:26       ` luigi scarso
@ 2012-05-27  1:43         ` Rogers, Michael K
  2012-05-27  2:49           ` Aditya Mahajan
  0 siblings, 1 reply; 9+ messages in thread
From: Rogers, Michael K @ 2012-05-27  1:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use figures without file extension
  2012-05-27  1:43         ` Rogers, Michael K
@ 2012-05-27  2:49           ` Aditya Mahajan
  2012-05-27 13:09             ` Rogers, Michael K
  0 siblings, 1 reply; 9+ messages in thread
From: Aditya Mahajan @ 2012-05-27  2:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use figures without file extension
  2012-05-27  2:49           ` Aditya Mahajan
@ 2012-05-27 13:09             ` Rogers, Michael K
  0 siblings, 0 replies; 9+ messages in thread
From: Rogers, Michael K @ 2012-05-27 13:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 856 bytes --]

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).

[-- Attachment #1.2: Type: text/html, Size: 1507 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-05-27 13:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-26  2:08 Use figures without file extension Aditya Mahajan
2012-05-26  9:28 ` Hans Hagen
2012-05-26 13:39 ` Hans Hagen
2012-05-26 14:04   ` Aditya Mahajan
2012-05-26 14:23     ` Hans Hagen
2012-05-26 14:26       ` luigi scarso
2012-05-27  1:43         ` Rogers, Michael K
2012-05-27  2:49           ` Aditya Mahajan
2012-05-27 13:09             ` Rogers, Michael K

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).