15

Often one or more images are required in minimal working examples or as part of some example code of and answer to make it compile successful and/or give some nice visual result. One problem is that this image can't be easily provided with the code. While the demo option of the graphicx package can be used to replace the image with a demo rectangle using real images is IMHO better and more accurate if more then one different images are required, for example to show how to align them. (Just happened to me in Placing images left and right of each other.)

To easy this we could have a set of official example images and promote the use of them in example code for both questions and answers. The images should be already located in some common LaTeX packages, so that most people already have them and (La)TeX can pick them up in the TEXMF tree without much hassle. A good example is the famous PostScript tiger locate in $TEXMF/doc/generic/pstricks/images/tiger.[pdf|eps].

Are there any other suitable images provided by common LaTeX packages? Having them in both EPS and PDF format would be great.

9

I vote for images from placekitten.com.

A placeholder of arbitrary width and height can be obtained by specifying pixel values in the URL:

http://placekitten.com/g/400/400

1600 square pixels of cuteness

Now, we just need a placekitten package that works out the details of fetching the URLs and converting them to EPS/PDF...

Also, omitting the g from the url results in a color photo:

http://placekitten.com/600/400

2400 square pixels of colorized cuteness

Awww...

  • 2
    I was talking about images already present in the TEXMF tree, i.e. provided by some standard packages, so that they can be used without requiring other people to install anything new. – Martin Scharrer May 3 '11 at 7:07
  • 3
    +1 for a \usepackage{placekitten}! – Habi May 3 '11 at 14:49
  • 6
    @Sharpie, @Habi: Using these images is fun. See my blog post for an macro that uses these images. – Aditya May 7 '11 at 23:34
  • @Aditya Very nice! I bet something could be cooked up using LuaTeX that would work in all three major TeX dialects. – Sharpie May 7 '11 at 23:45
  • @Sharpie: The harder part is downloading the image and storing it in a cache and reusing it in subsequent runs. ConTeXt provides a generic mechanism for this. For a generic soln, that mechanism needs to be ported to other formats – Aditya May 8 '11 at 0:18
  • @Aditya The downloading should be pretty easy since LuaTeX includes the socket library. You can execute the following in directlua: socket.http.request{url = 'http://placekitten.com/300/300', sink = ltn12.sink.file(io.open('tst.png','w'))}. Just needs some caching and error checking. – Sharpie May 8 '11 at 0:57
  • Erp. ImageMagick's identify confirms that placekitten returns JPEG images, so .png would be the wrong extension. – Sharpie May 8 '11 at 22:17
  • You guys are great! Thanks @Aditya for providing a macro! – Paulo Cereda May 11 '11 at 19:51
3

ConTeXt provides some images in the $TEXMF/tex/context/sample directory: cow.pdf, hacker.jpg, mill.png, and spider.eps. But I don't think that these can used as sample images for LaTeX examples because most LaTeX users might not have ConTeXt installed.

Another approach followed in the ConTeXt community for dummy figures is drawing random dummy figures using metapost. For example, if you just need to draw an image that is 4cm wide and 3cm high, you can use

\useMPlibrary[dum] %This overloads \externalfigure macro

and then

\externalfigure[whatever][width=4cm, height=3cm]

If the figure whatever is not found in the current directory, then ConTeXt will draw a random figure of the requested dimensions. It is relatively straight forward to add this fallback, but I don't know if any LaTeX package does that.

  • $TEXMFDIST/tex/context/sample doesn't contain any images in Texlive 2010; cow.pdf is under $TEXMF/doc. – Charles Stewart May 3 '11 at 12:50
  • @Charles: That means that only context minimals include those files. Then they are definitely not a good candidate for sample images. – Aditya May 4 '11 at 3:44
1

The documentation for the image-gallery class has a number of pictures as JPEGs. Unfortunately I don't think they are accessible from kpathsea, which means they can't be directly be accessed in Tex/Latex in the usual way, but they are accessible using texdoc: the Bash line texdoc -l -I image-gallery | (read -ra LINE; echo $(dirname ${LINE[1]})) should give the directory containing the images (/usr/local/texlive/2010/texmf-dist/doc/latex/image-gallery on my main machine), which are numbered pic001.jpg to pic022.jpg.

Is this any use?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .