How can I use includegraphics when I want to include an image which has no extension?

When I try to set type=jpg by hand I get the following error: LaTeX Error: Cannot determine size of graphic in images/posters/sample (no size specified)

If I change the sample to sample.jpg all works, but I have a bunch of theses images for which I cannot change the suffix (another application depends on it).

Any advice?

  • 1
    If you cannot change the original name of the image you could use a link/alias/whatever this is called on your OS with the name sample.jpg that links to sample. – user36296 Jul 25 '17 at 12:57
  • Sure, but the problem is I am including images from another system, and would prefer to avoid the overhead of copying / linking to images. Moreover, I have thousands of said images... – nir Jul 25 '17 at 13:06
  • Generating the links can be automated ... – user36296 Jul 25 '17 at 13:07
  • Call me lazy, but I would think there is a simple solution inside Latex – nir Jul 25 '17 at 13:10
  • b.t.w, tried adding "\DeclareGraphicsExtensions{.pdf,.png,.jpg,}% Note the trailing ',' which defines an empty extension", but still am getting an error – nir Jul 25 '17 at 13:10

I can't think of a simple solution, but here's a possible solution that adapts the internals command used by \includegraphics.


   \Gin@viewport@code\Gin@nat@height\Gin@ury bp%
   \advance\Gin@nat@height-\Gin@lly bp%
   \Gin@nat@width \Gin@urx bp%
   \advance\Gin@nat@width-\Gin@llx bp%
   \expandafter\ifx\csname Ginclude@jpg\endcsname\relax
     \expandafter\ifx\csname Gread@jpg\endcsname\relax
       \@latex@error {Can not include graphics of type: jpg}\@ehc
     \Gin@req@width{\vrule \hss \vbox to \Gin@req@height{\hrule \@width
      \Gin@req@width \vss
    \ProvidesFile{\Gin@base}[Graphic file (type jpg)]%



\includejpgnoext{sample} % jpg image file called 'sample' with no extension   

It only works with PDFLaTeX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.