Generate custom playing cards, especially for tabletop games.
The main script takes as arguments a configuration json file and a decklist file. The configuration is responsible for defining the parameters of your card design. For instance, which card type to use, the placement of the art, and from where to source your assets. The decklist is a .csv file with the columns expected for the card type. A copy of the example output is in example/example_output.png
.
- Generates decklist images (usable with Tabletop Simulator) from assets and decklists in either local folders or Google drive.
- Uses flexible configuration to define card layout and other build parameters.
- Supports placing images and drawing text. So far there is an additional image layer for rendering in a line symbols mapped from text. The text layer supports wrapping, automatic font sizing, newlines, and image embeddings.
There are two example configurations. Each generates the the same card type, but one uses local assets while the other reads them from Google drive.
The flexibility of the input configuration can make it difficult to know what parameters are supported. scripts/card_layer_factory.py
is a good source of truth for card layers, and scripts/config_enums.py
should help with understanding appropriate parameter values. The example is already configured for a number of layer types along with other necessary build parameters. To generate it:
python ./scripts/main.py --config './example/example_local_config.json' --decklist './example/assets/lists/example-local.csv'
The example renders a card defined in a Google sheet, using images stored in Google drive. You'll need to do some set up, however, due to Google drive permissions. The app can only interact with files it created in your drive or a shared one. To get started you'll need to upload the assets to the drive.
Download the app credentials json. The example config expects it to be in credentials.json
(which is in the .gitignore
), but you can change that to point anywhere.
Pick a folder to upload your assets to, and grab its id from the share url. To create an empty decklist in the remote folder <folder_id>
:
python ./scripts/google_create_csv --creds './credentials.json' --name 'example' --folder_id '<folder_id>'
This will print the Id of the created spreadsheet, <decklist_id>
. However, you should be able to refer to the assets by name in your configuration and decklists.
The columns names in the decklist are referenced by the corresponding CardBuilder
implementation, in this case the ExampleCardBuilder
. Refer to examples/assets/lists/example-local.csv
or the builder implementation itself to populate the decklist.
To upload an image <image_file>
in <folder_id>
:
python ./scripts/google_upload_png --creds './credentials.json' --file <image_file> --name 'example_image.png' --folder_id '<folder_id>'
Alternatively specify --update_id
to update an existing image. You can use the images in example/assets/images/
.
Update example/example_google_config.json
with the names of the files you uploaded (specifying the "google_assets_folder_id"
enables reference by name rather than id).
python ./scripts/main.py --config './example/example_google_config.json' --decklist '<decklist_name>'