I am not sure how to find out what all is included as curated data. For example, are the individual images of each of the 52 cards in a standard deck of playing cards included?

If not, is there a way to systematically access these from web images?

  • $\begingroup$ have you checked the help item howto/UseCuratedData? That lists the available curated data. $\endgroup$
    – Zviovich
    Commented Dec 11, 2012 at 18:15
  • $\begingroup$ I'm not sure if standard images of a deck of cards is included in the curated data, but you should be able to "Import" if you can find the images you want. $\endgroup$
    – cartonn
    Commented Dec 11, 2012 at 18:18
  • $\begingroup$ A google search yielded this. You would need to import it, then partition the image. $\endgroup$
    – VF1
    Commented Dec 11, 2012 at 18:26
  • $\begingroup$ @DiegoZviovich: Yes, I always try to find things myself before asking. However, some of the categories/classes listed are vague, e.g., ExampleData. I hunted but could not find playing cards and thought someone might know if/where they might be hiding before trying to manually construct such a thing. $\endgroup$
    – JohnD
    Commented Dec 11, 2012 at 18:27

6 Answers 6


You can get some nice vector playing cards from this site, licensed under GNU LGPL (read more here). Download this folder to your computer and then try the following:

(* replace with your download dir *)
files = Flatten@With[{dir = "~/Downloads/Chrome/mma/SVG_and_EPS_Vector_Playing_Cards_Version_1.3/EPS_Vector_Playing_Cards_Version_1.3/52-Individual-Vector-Playing-Cards-1.2_(EPS-Format)/"},
    FileNames["*.eps", dir, 2]];

SetAttributes[CardData, Listable]
StringCases[Last@FileNameSplit@#, card__ ~~ ".eps" :> 
    (CardData[card] = ImageCrop@Import@#)] & /@ files;

You can then use this like any other curated data:

GraphicsRow[CardData@{"2C", "KH", "AS", "QD", "JC"}]

Random hand generator:

You can extend this further and also create a random hand generator using Mathematica as follows:

deck = Flatten@With[
        ranks = CharacterRange["2", "9"] ~Join~ {"10", "J", "Q", "K", "A"}, 
        suits = {"C", "S", "H", "D"}
    Outer[StringJoin, ranks, suits]
dealHand[n_Integer] /; 1 ≤ n ≤ 52 := CardData@RandomSample[deck, n]

Use this to deal a hand as dealHand[5], for instance. You'll have to modify this a bit to deal randomly and exhaust the deck at the same time (as you would in a game). There was a question on this previously on this site and I gave an answer based on Internal`Bag[] that will be useful here (along with some of the other answers there).

  • $\begingroup$ Thanks, this is certainly the realistic looking effect I was after (and hence is very useful for me since I can finish my task). It would be great to have a complete set of realistic looking playing cards accessible via built-in curated data. Maybe in the future? $\endgroup$
    – JohnD
    Commented Dec 11, 2012 at 19:45
  • $\begingroup$ Thanks for your input, just used that to create a simple math lesson on introductory probability, and this was just what I needed to make it work! $\endgroup$ Commented Apr 17, 2013 at 17:41
  • $\begingroup$ This is great info. Just a quick note -- the site referenced by the user rm -rf above: code.google.com/p/vectorized-playing-cards/downloads/… Now gets re-directed to: sourceforge.net/projects/vector-cards While this may not be what the original requestor was asking, it is a really nice site for playing card graphics. $\endgroup$
    – G. Khanna
    Commented Jan 28, 2018 at 4:37
  • 1
    $\begingroup$ These cards have been moved again and provided in a completely different format...totalnonsense.com/open-source-vector-playing-cards namely a single svg file containing all cards, this code is unfortunately unequipped for the task anymore :( $\endgroup$ Commented Nov 7, 2019 at 20:34

Not super high quality, but this might do for some purposes:

cards = Join[
  Table[ToString[k], {k, 2, 10}],
  {"Jack", "Queen", "King", "Ace"}];
suits = {"hearts", "diamonds", "clubs", "spades"};
deck = Flatten[Outer[#2 <> " of " <> #1 &, suits, cards]];
images = Table[
  WolframAlpha[card, {{"Image", 1}, "Content"}], {card, deck}];
Grid[Partition[images, 13]]

enter image description here

In terms of your real question, namely "how to find out what all is included as curated data", I had no clue if playing card images were included or not. I simply asked Wolfram Alpha via a query like so:

enter image description here

Choosing "Subpod content" as shown, I learned that the command to access the image is

WolframAlpha["4 of clubs", {{"Image", 1}, "Content"}]

I couldn't figure out how to access the whole deck at once, but from here I was able to put the whole thing together programmatically.

  • 1
    $\begingroup$ Thanks! This really answers my larger question: how to determine if a certain piece of data I'm after is even accessible (in curated form) within Mathematica, and if so, how to access it. $\endgroup$
    – JohnD
    Commented Dec 11, 2012 at 18:50
  • 1
    $\begingroup$ So, are these cards really somewhere on my hard drive within the MMA files or are they just in some WolframAlpha server? $\endgroup$
    – VF1
    Commented Dec 11, 2012 at 18:54
  • $\begingroup$ @VF1 My guess is that the images are not just on your hard drive, rather they're globally accessible via WolframAlpha's servers. I guess I don't know for sure, since WolframAlpha uses many of Mathematica's built in Data Paclets. $\endgroup$ Commented Dec 11, 2012 at 19:06

I don't know if this question is specifically asking about finding images in MMA's data, but if the end goal is to get playing card images, then using an online image and partition seems to work great. Link to image

     Import["http://www.milefoot.com/math/discrete/counting/images/cards.png"],{73, 98}] // Grid

enter image description here

Edit: The lack of a top outline over the third row of cards is an artifact of the pdf I saved the image as, not the actual MMA output. Also, the slightly thicker right side outline is a property of the image, which is supposed to have a shadow. This can be removed programmatically if needed.

Finally, I suppose that the way I went about extracting the individual card images from the imported image could have been more elegant than what I did, but I don't think there's an issue with trial and error for finding the card dimensions if it's just as effective as whatever the more elegant code is.

  • $\begingroup$ My first question was if it were accessible in some Wolfram-curated form (see Mark McClure's answer above). But then if not, how to bring in "external" data from the web and go to work using it. Your reply helps me with the latter (although I'm not sure how to slice up this single image into the relevant subimages I'd need). $\endgroup$
    – JohnD
    Commented Dec 11, 2012 at 18:52
  • $\begingroup$ @JohnD I sliced it up for you. If you remove the //Grid, then it will become a 2-dimensional array of playing card images. The Grid was there for display purposes. Mark's answer does more directly address what you asked for, though. I just think mine looks cooler. $\endgroup$
    – VF1
    Commented Dec 11, 2012 at 18:55
  • $\begingroup$ Yours is indeed very cool! $\endgroup$
    – JohnD
    Commented Dec 11, 2012 at 20:23

It is not entirely clear to me whether the playing cards in your question are just an example of what you want to find or the actual target. Since the other answers already provide you with the latter I'll provide a way to explore ExampleData.

The following two lines of code will build a complete overview of what's hidden in there. Running it may take a bit of time as most of the data will have to be transfered from the Wolfram server to your local paclet store for the first time.

switchedDisplay[stuff_] :=  
       Row[{"Show:  ", Checkbox[Dynamic[x]], "    ", 
             Dynamic[If[x, ExampleData@stuff, stuff], SynchronousUpdating -> False]}]
TabView[# -> TabView[switchedDisplay /@ ExampleData[#]] & /@ ExampleData[]]

Mathematica graphics Mathematica graphics Mathematica graphics Mathematica graphics


MacOs doesn't seem to like long TabViews, so the code may have to be changed a little bit.

This adds another layer of TabViews where necessary:

MacMax = 30;
TabView[# -> 
    TabView[If[Length@ExampleData[#] > MacMax, 
      TabView /@ Partition[switchedDisplay /@ ExampleData[#], MacMax],
       switchedDisplay /@ ExampleData[#]]] & /@ ExampleData[]]

MacOS user MarkMcClure reports that ControlPlacement -> {Top, Left} in TabView also prevents problems from occurring.

  • $\begingroup$ I am indeed interested in whether the deck of cards, specifically, is internally curated by Wolfram. However, this led naturally to a more general question: how can I get an inventory of all Wolfram-curated data? It seems that this is a good, separate questions which others might search for. I don't know the protocol here, but should this be spun off as a separate, stand-alone question (with your answer of course)? Please advise. $\endgroup$
    – JohnD
    Commented Dec 11, 2012 at 20:21
  • $\begingroup$ @JohnD I don't think that's necessary. Perhaps, you could just edit the title to emphasize the "curated data" aspect, rather than the "playing card" aspect. The latter is in the question anyway. $\endgroup$ Commented Dec 11, 2012 at 20:24
  • $\begingroup$ @MarkMcClure: I see your point, but with two "real" questions here, I am conflicted on what to accept as "the" answer. $\endgroup$
    – JohnD
    Commented Dec 11, 2012 at 20:28

Did you see Mathematica Package for Texas Hold'em from Sal Mangano. It's a Poker Simulation Library in Mathematica from http://www.mathematicacookbook.com. The code covers parsing cards, monte carlo simulation, a game engine as well as visual interface with cards. You can access also the images of cards from this link of same library.


In versions 11.3+, you can use Jon McLoone's ResourceFunction["PlayingCardGraphic"]

playingcardgraphic = ResourceFunction["PlayingCardGraphic"];

playingcardgraphic[RandomSample[Range @ 52, 5]]

enter image description here

Multicolumn[playingcardgraphic /@ Range[52], 13, 
  Appearance -> "Horizontal", Spacings -> {0, 0}]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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