Token image Filenames Algorithm
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
9 posts
• Page 1 of 1
Token image Filenames Algorithm
by necxelos » 10 Jul 2019, 01:08
Hello everyone
Since it's my first post I'll start by thanking Forge authors for their amazing job. This is probably the best (and surely the most accessible since it's the only one with mobile version) MtG playing app there is and I totally love it.
To the topic itself though. I've made an app that downloads HD card images for me to use in Forge. It also converts HD images from big-mb PNG's to small-mb JPG's (more or less without quality loss), cuts borders from images so they fit the Forge programmatic card borders and names all files and folders accordingly.
Everything works as intended for cards. But then tokens come along and... I'm lost! What is the naming convention here? Can someone describe it to me (as precisely as possible)?
Thanks in advance
necxelos
Since it's my first post I'll start by thanking Forge authors for their amazing job. This is probably the best (and surely the most accessible since it's the only one with mobile version) MtG playing app there is and I totally love it.
To the topic itself though. I've made an app that downloads HD card images for me to use in Forge. It also converts HD images from big-mb PNG's to small-mb JPG's (more or less without quality loss), cuts borders from images so they fit the Forge programmatic card borders and names all files and folders accordingly.
Everything works as intended for cards. But then tokens come along and... I'm lost! What is the naming convention here? Can someone describe it to me (as precisely as possible)?
Thanks in advance
necxelos
CGB Decks & Video Guides viewtopic.php?f=48&t=30357
HQ AI-Enhanced Card Pictures viewtopic.php?f=15&t=31289
HQ AI-Enhanced Card Pictures viewtopic.php?f=15&t=31289
Re: Token image Filenames Algorithm
by friarsol » 10 Jul 2019, 01:31
// Expected naming convention of scripts
// token_name
// minor_demon
// marit_lage
// gold
// colors_power_toughness_cardtypes_sub_types_keywords
// Some examples:
// c_3_3_a_wurm_lifelink
// w_2_2_knight_first_strike
// The image names should be the same as the script name + _set
You can see the names of all token scripts here:
https://git.cardforge.org/core-develope ... kenscripts
And if you look in the specific editions files you can see which set owns which tokens
https://git.cardforge.org/core-develope ... Revolt.txt
// token_name
// minor_demon
// marit_lage
// gold
// colors_power_toughness_cardtypes_sub_types_keywords
// Some examples:
// c_3_3_a_wurm_lifelink
// w_2_2_knight_first_strike
// The image names should be the same as the script name + _set
You can see the names of all token scripts here:
https://git.cardforge.org/core-develope ... kenscripts
And if you look in the specific editions files you can see which set owns which tokens
https://git.cardforge.org/core-develope ... Revolt.txt
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Token image Filenames Algorithm
by Bog Wraith » 10 Jul 2019, 14:30
The links provided for this token procedure is wonderful to have. It answers alot of things I've wondered about but wasn't sure how the process for naming and image targeting were used in scripting these in.
Thanks for the links Sol. I'm not a coder, but this still will help me answer & understand many of the questions related to how Forge handles tokens!
Thanks for the links Sol. I'm not a coder, but this still will help me answer & understand many of the questions related to how Forge handles tokens!
'Twas in the bogs of Cannelbrae
My mate did meet an early grave
'Twas nothing left for us to save
In the peat-filled bogs of Cannelbrae.
My mate did meet an early grave
'Twas nothing left for us to save
In the peat-filled bogs of Cannelbrae.
-
Bog Wraith - Global Mod 1 (Ret)
- Posts: 1108
- Joined: 28 May 2008, 22:40
- Location: Shandalar
- Has thanked: 425 times
- Been thanked: 153 times
Re: Token image Filenames Algorithm
by friarsol » 11 Jul 2019, 00:42
I had written up a whole long thing about this when we were first releasing the change, but I think it got deleted by accident when I was trying to delete a whole bunch of spam 

- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Token image Filenames Algorithm
by necxelos » 12 Jul 2019, 17:40
Thank You very much for Your answer friarsol.
The colors_power_toughness_cardtypes_sub_types_keywords part is pretty self explanatory and easy to recreate programmaticaly from cards database. But I see a gigantic problem with _set addition at the end. You see, most tokens weren't released as part of the set and rather as part of promo-pack later down the road. That changed later, when tokens were added in booster packs, thus they became parts of the set, but that started being a thing only few years ago.
Could You please tell me how are You generating this last part of token file names?
There is another problem too. There is load of tokens that doesn't follow naming convention You provided: wirefly_dst, wasp_leb, volrath's_laboratory_sth to name just a few. What are those?
And last thing: there's plethora of custom-made tokens there, that were never released by WotC. How do I make Forge use only actual tokens? Examples: r_1_1_goblin_5ed, r_1_1_goblin_nms.
Thanks in advance for further answers.
The colors_power_toughness_cardtypes_sub_types_keywords part is pretty self explanatory and easy to recreate programmaticaly from cards database. But I see a gigantic problem with _set addition at the end. You see, most tokens weren't released as part of the set and rather as part of promo-pack later down the road. That changed later, when tokens were added in booster packs, thus they became parts of the set, but that started being a thing only few years ago.
Could You please tell me how are You generating this last part of token file names?
There is another problem too. There is load of tokens that doesn't follow naming convention You provided: wirefly_dst, wasp_leb, volrath's_laboratory_sth to name just a few. What are those?
And last thing: there's plethora of custom-made tokens there, that were never released by WotC. How do I make Forge use only actual tokens? Examples: r_1_1_goblin_5ed, r_1_1_goblin_nms.
Thanks in advance for further answers.
CGB Decks & Video Guides viewtopic.php?f=48&t=30357
HQ AI-Enhanced Card Pictures viewtopic.php?f=15&t=31289
HQ AI-Enhanced Card Pictures viewtopic.php?f=15&t=31289
Re: Token image Filenames Algorithm
by friarsol » 12 Jul 2019, 18:07
It has nothing to do with actual token cards that were physically printed. Forge only cares about the set of the card that is generating the token. It attempts to use that same set, then it falls back to the default name.
The first two examples of things you list that don't follow the naming convention do in fact follow the naming convention. These are NAMED tokens. Most tokens are not named they just have types, so their name becomes the same as their subtypes. (ex. Human Soldier) All of these style tokens follow the unnamed token rules.
However, for the small handful of tokens that have names https://scryfall.com/search?q=o%3A%22to ... order=name they follow the regular image naming rules. It's just `name_set`. This was listed in my last post:
// Expected naming convention of scripts
// token_name
// minor_demon
// marit_lage
// gold
There are some special cases like Volrath's Laboratory, where we don't actually know what the type will be at script time. So they are just named after the originating card.
I don't really know what your last question means. But delete the image so it uses a default one maybe?
The first two examples of things you list that don't follow the naming convention do in fact follow the naming convention. These are NAMED tokens. Most tokens are not named they just have types, so their name becomes the same as their subtypes. (ex. Human Soldier) All of these style tokens follow the unnamed token rules.
However, for the small handful of tokens that have names https://scryfall.com/search?q=o%3A%22to ... order=name they follow the regular image naming rules. It's just `name_set`. This was listed in my last post:
// Expected naming convention of scripts
// token_name
// minor_demon
// marit_lage
// gold
There are some special cases like Volrath's Laboratory, where we don't actually know what the type will be at script time. So they are just named after the originating card.
I don't really know what your last question means. But delete the image so it uses a default one maybe?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Token image Filenames Algorithm
by necxelos » 12 Jul 2019, 19:06
Ok let me rephrase the problem. I don't work with Forge source code.
My startpoint is a scryfall database dump (available as bulk data on their website) from which my app downloads images and places them in directories the scryfall way. I work my way to Forge from there: convert files, create Forge folder structure, create forge file names.
And that works for cards very well. But it doesn't work for tokens at all. My startpoint for tokens is the same as for cards. I have folders codenamed "tri-letter-expansion-code" and I have token file name. Now the trick is to go from there to Your naming convention. And that's a hell of a trick to pull of. Database stores information about power, toughness, type and color identity. Keywords I can only guess from card text and it's already a big problem and connection to a set is nonexistent so it seems bloody impossible.
Any ideas how to go from that point to Forge token name?
My startpoint is a scryfall database dump (available as bulk data on their website) from which my app downloads images and places them in directories the scryfall way. I work my way to Forge from there: convert files, create Forge folder structure, create forge file names.
And that works for cards very well. But it doesn't work for tokens at all. My startpoint for tokens is the same as for cards. I have folders codenamed "tri-letter-expansion-code" and I have token file name. Now the trick is to go from there to Your naming convention. And that's a hell of a trick to pull of. Database stores information about power, toughness, type and color identity. Keywords I can only guess from card text and it's already a big problem and connection to a set is nonexistent so it seems bloody impossible.
Any ideas how to go from that point to Forge token name?
CGB Decks & Video Guides viewtopic.php?f=48&t=30357
HQ AI-Enhanced Card Pictures viewtopic.php?f=15&t=31289
HQ AI-Enhanced Card Pictures viewtopic.php?f=15&t=31289
Re: Token image Filenames Algorithm
by Diogenes » 13 Jul 2019, 20:35
If you're comfortable with brute force copy/pasting, the following steps should work:necxelos wrote:And that works for cards very well. But it doesn't work for tokens at all. My startpoint for tokens is the same as for cards. I have folders codenamed "tri-letter-expansion-code" and I have token file name. Now the trick is to go from there to Your naming convention. And that's a hell of a trick to pull of. Database stores information about power, toughness, type and color identity. Keywords I can only guess from card text and it's already a big problem and connection to a set is nonexistent so it seems bloody impossible.
Any ideas how to go from that point to Forge token name?
1. Open Forge and go to the Content Downloaders pane
2. Click on the Audit Card and Image Data button
3. Once that step is complete, click the Copy to Clipboard button and paste the audit into your favorite text editor
4. Sort through your images and copy/paste the proper filenames from the document
5. Place those images into forge/cache/pics/tokens
Two things to note:
If a token appears in a set, and subsequent sets in the same block have token generators but do not have the token, the cards will look for a duplicate of the token image as if it were printed in the later set (for instance w_1_1_soldier_ths should be copied as w_1_1_soldier_jou.) There are a lot of duplicates like this, but they're all pretty obvious.
Also, in some edge cases you'll find tokens missing in game despite being accounted for (for instance, the emblem created by Ajani, Adversary of Tyrants creates 1/1 Cat tokens. These tokens don't use w_1_1_cat_lifelink_m19, but will appear if you make a copy named w_1_1_cat_lifelink. I'm not sure if this behavior is intentional.) If you come across a token whose image isn't loading you can always read the card script that created that token to see the file name it wants to load.
Alternatively, you could just use the integrated downloader to populate your token folder and then sort out replacing the images on a file-by-file basis.
(Edit: I realize it seems like I'm missing the point, I should have led with this disclaimer. I get that you want to automate the process, but I cannot think of a clean way to accomplish that. Certain tokens with verbose abilities like "This creature gets +1/+1 for each artifact you control" get tagged as "c_0_0_a_construct_total_artifacts". I'm sure you could get it to work using Color/P/T comparisons and the list of supported token file names, but I can confirm it doesn't take all that long to do by hand. Also: not a dev.)
Re: Token image Filenames Algorithm
by necxelos » 13 Jul 2019, 22:06
Personally I think I could do all that renaming by hand, yes.
There are a lot of tokens and I still think it's a mental thing to do manually but not impossible.
Thing is, I intend my App to be used by other people once I consider it usable (don't worry, when that happens I'll post it here too) and I'm making it to work with plethora of MtG apps, not just Forge. For example I can already convert card images to both Forge and Cockatric filesystem (there are lots of differences).
So one way or another I still need an idea of how to convert state A (token images from Scryfall) into state B (token images for Forge) without any manual work, other than running my App.
There are a lot of tokens and I still think it's a mental thing to do manually but not impossible.
Thing is, I intend my App to be used by other people once I consider it usable (don't worry, when that happens I'll post it here too) and I'm making it to work with plethora of MtG apps, not just Forge. For example I can already convert card images to both Forge and Cockatric filesystem (there are lots of differences).
So one way or another I still need an idea of how to convert state A (token images from Scryfall) into state B (token images for Forge) without any manual work, other than running my App.
CGB Decks & Video Guides viewtopic.php?f=48&t=30357
HQ AI-Enhanced Card Pictures viewtopic.php?f=15&t=31289
HQ AI-Enhanced Card Pictures viewtopic.php?f=15&t=31289
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 30 guests