I have 52 PNG files on my machine, one for each playing card in a standard deck. I'm trying to make a poster to display all 3744 possible full house hands in a game of poker, arranged in a grid like 78 rows by 48 columns (or whatever looks good for the wall space I have). The PNG files themselves are small, no more than 40KB, but there are going to be more than 18000 of them in the finished file. Still, this should be possible, right? :-)

Heh. This is breaking my machine, and I'm not sure why. I have a deck object and a cards Association[] that points each object in deck to a file on my machine.

deck = Flatten[
   {rank, suit},
   {rank, Join[Range[2, 10], {j, q, k, a}]},
   {suit, {\[SpadeSuit], \[HeartSuit], \[DiamondSuit], \[ClubSuit]}}
cards = 
   Flatten @ Table[
       Flatten[Append[Range[10], {j, q, k, a}]][[n]], 
       { \[ClubSuit], \[DiamondSuit], \[HeartSuit], \[SpadeSuit]}[[
       } ->
          "number" -> ToString[n],
          "suit" -> ToString[b]
        ], .75], {n, 2, 14}, {b, 4}

I also have a fullHouseQ[] function, so I have a fullHouses variable as well as a cardsToHand[] function and a fullHouseHands variable; the last of these contains a list of 5 PNG figures from my machine.

fullHouses = 
   Subsets[deck, {5}],
   fullHouseQ[#] &

cardsToHand[hand_] := Row[Map[cards[#] &, hand]]

fullHouseHands = cardsToHand /@ fullHouses;

For example, cardsToHand[fullHouses[[616]]] generates this output. I can save this single hand as a 100KB PDF or as a 25KB PNG image file.

an example full house

However, if I try to combine Export[], Partition[], and TableForm[], things go awry.

 "pathname", (* this is correct for my machine :-) and it works at small grid sizes *)
  TableSpacing -> {2, 2}

The computer works and works and works, and eventually returns something like this:

enter image description here

I'm not sure why, but if I don't try to Partition[] and TableForm[] the output, I am able to generate a list of 3744 5-card hands, and I can even export them into a PDF. The file, however, is ~250MB big, though I suppose that'll happen even in the version I want. There are also extra curly braces and commas that I don't want in the finished version.

Anyone have any thoughts on this? I appreciate any direction you can offer.

  • $\begingroup$ PNG is a loss less format. Maybe if you use e.g. JPEG, that is not loss less, your file becomes smaller. $\endgroup$ Oct 6, 2022 at 9:12

1 Answer 1


You could try using ImageAssemble instead of TableForm, but the output image would be very large:

In[1]:= img = Import["https://i.sstatic.net/GIB7f.png"];

In[2]:= fullHouseHands = ConstantArray[img, 3744];

In[3]:= out = ImageAssemble[Partition[fullHouseHands, 48], Spacings -> 40, Background -> Transparent];

In[4]:= ImageDimensions[out]

Out[4]= {47000, 24764}

It would be better to store each 5-card image as a separate frame in an animated PNG format:

In[5]:= FileSize[Export["out.png", fullHouseHands]]

Out[5]= Quantity[87.4191, "Megabytes"]

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.