├── svg2png.py ├── README.md └── cards-svg ├── 2S.svg ├── 3S.svg ├── 4S.svg ├── 5S.svg ├── 6S.svg ├── 2C.svg ├── 7S.svg ├── 8S.svg ├── 3C.svg ├── 9S.svg ├── 4C.svg ├── 5C.svg ├── Joker1.svg ├── 6C.svg ├── 2H.svg ├── 10S.svg ├── AC.svg ├── Joker2.svg ├── 3H.svg ├── 7C.svg └── 2D.svg /svg2png.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Copyright 2014 Peter Tripp 5 | Licensed under the MIT License: http://opensource.org/licenses/MIT 6 | """ 7 | 8 | import argparse 9 | import os 10 | import subprocess 11 | 12 | if __name__=="__main__": 13 | parser = argparse.ArgumentParser(description="Generate fixed width PNGs from SVGs") 14 | parser.add_argument("-i", "--inputdir", required=True, help="Input directory of SVGs") 15 | parser.add_argument("-o", "--outputdir", required=True, help="Output directory of PNGs") 16 | parser.add_argument("-v", "--verbose", action="store_true", default=False, help="No output") 17 | parser.add_argument("-x", "--nocrush", action="store_true", default=False, help="Don't optimize resulting PNGs") 18 | parser.add_argument("-n", "--dry-run", action="store_true", default=False, help="Show commands without running them") 19 | parser.add_argument("-w", "--width", required=True, type=int, help="PNG output width") 20 | 21 | args = parser.parse_args() 22 | if not os.path.exists(args.inputdir): 23 | parser.error('Input directory does not exist') 24 | elif " " in args.inputdir or " " in args.outputdir : 25 | parser.error('Input directory or output directory contains a space.') 26 | #trailing slashes 27 | if args.inputdir[-1] != os.sep : args.inputdir += os.sep 28 | if args.outputdir[-1] != os.sep : args.outputdir += os.sep 29 | if not os.path.exists(args.outputdir): os.makedirs(args.outputdir) 30 | 31 | cmd, counter = [], 0 32 | for (counter, filename) in enumerate(os.listdir(args.inputdir)): 33 | if not filename.endswith(".svg"): 34 | pass #print filename + ":" not .svg 35 | else : 36 | li = [] 37 | name, ext = os.path.splitext(filename) 38 | infile = os.path.join(args.inputdir, filename) 39 | outfile = os.path.join(args.outputdir, name + ".png") 40 | li.append(["svg2png", "-w", str(args.width), infile, outfile]) 41 | if not (args.nocrush): 42 | li.append(["optipng", "-o3", outfile, "-q"]) 43 | #results in 3-5% space savings 44 | #li.append(["advdef", "-3", outfile, "-q"]) 45 | cmd.append(list(li)) 46 | if args.verbose : print "Found", counter, "files. Beginning conversion." 47 | 48 | for eachfile in cmd : 49 | for c in eachfile : 50 | if (args.dry_run or args.verbose): 51 | print ' '.join(c) 52 | if not args.dry_run: 53 | subprocess.call(c) 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vector Playing Cards 2 | 3 | This is a simple collection of SVG images defining a deck of playing cards (based on [vector-playing-cards][4]) and a script (svg2png.py) which will convert a folder of svg files into arbitrarily sized png files. 4 | 5 | ## Usage: 6 | svg2png.py [-h] -i INPUTDIR -o OUTPUTDIR [-q] [-x] [-n] -w WIDTH 7 | 8 | Generate fixed width PNGs from SVGs 9 | optional arguments: 10 | -h, --help show this help message and exit 11 | -i INPUTDIR Input directory of SVGs 12 | -o OUTPUTDIR Output directory of PNGs 13 | -v, --verbose Verbose output 14 | -x, --nocrush Don't optimize resulting PNGs 15 | -n, --dry-run Show commands without running them 16 | -w WIDTH PNG output width 17 | 18 | ## Example use: 19 | 20 | * Simple: Convert SVGs to 300px wide uncompressed PNGs: 21 | 22 | `python svg2png.py -v -x -i cards-svg -o cards-png-300px -w 300` 23 | 24 | * Normal: Create SVGs to 320px wide optimized PNGs suppressing all status output 25 | 26 | `python svg2png.py -i cards-svg -o cards-png-320px -w 320` 27 | 28 | 29 | ## Prerequisites: 30 | To generate custom PNG images, you'll want the following tools: 31 | 32 | * MacOSX: 33 | * Homebrew: `ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"` 34 | * svg2png: `brew install svg2png` 35 | * optipng: `brew install optipng` 36 | * advdef: `brew install advancecomp` 37 | * montage: `brew install imagemagick` 38 | 39 | * Python 2.7 (generate-png.py uses argparse which is Python 2.7 only) 40 | 41 | ## Notes: 42 | Non optimized PNGs are approximately a third larger. 43 | 44 | ##License 45 | 46 | These images, scripts and subsequent transformational output (e.g. custom sized PNGs) are released into the public domain or optionally licensed under the [WTFPL][2] in juristictions where the public domain is not a recognized legal concept. Either way, do as you see fit: relicense, embed in commercial, non-commercial or open-source software, etc. 47 | 48 | The original source images were released by [Byron Knoll][3] into the public domain on Google Code as [vector-playing-cards][4] . Perhaps send him 49 | 50 | 51 | [1]: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager 52 | [2]: http://en.wikipedia.org/wiki/WTFPL 53 | [3]: http://www.byronknoll.com/ 54 | [4]: https://code.google.com/p/vector-playing-cards/ 55 | 56 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/notpeter/vector-playing-cards/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 57 | 58 | -------------------------------------------------------------------------------- /cards-svg/2S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 2 102 | 103 | 104 | 112 | 2 132 | 133 | 148 | -------------------------------------------------------------------------------- /cards-svg/3S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 3 102 | 103 | 104 | 112 | 3 132 | 133 | 155 | -------------------------------------------------------------------------------- /cards-svg/4S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 4 102 | 103 | 104 | 105 | 113 | 4 133 | 134 | 135 | 164 | -------------------------------------------------------------------------------- /cards-svg/5S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 5 102 | 103 | 104 | 105 | 113 | 5 133 | 134 | 135 | 171 | -------------------------------------------------------------------------------- /cards-svg/6S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 6 102 | 103 | 104 | 105 | 113 | 6 133 | 134 | 135 | 178 | -------------------------------------------------------------------------------- /cards-svg/2C.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 116 | 119 | 123 | 126 | 128 | 129 | 130 | 131 | 132 | 134 | 135 | 136 | 138 | 139 | 140 | 143 | 145 | 146 | 147 | 148 | 149 | 152 | 154 | 155 | 156 | 157 | 158 | 159 | 2 171 | 172 | 173 | 174 | 175 | 176 | 2 195 | 196 | 197 | 198 | 217 | -------------------------------------------------------------------------------- /cards-svg/7S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 7 102 | 103 | 104 | 105 | 106 | 114 | 7 134 | 135 | 136 | 137 | 187 | -------------------------------------------------------------------------------- /cards-svg/8S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 8 102 | 103 | 104 | 105 | 106 | 107 | 115 | 8 135 | 136 | 137 | 138 | 139 | 196 | -------------------------------------------------------------------------------- /cards-svg/3C.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 116 | 119 | 123 | 126 | 128 | 129 | 130 | 131 | 132 | 134 | 135 | 136 | 138 | 139 | 140 | 143 | 145 | 146 | 147 | 148 | 149 | 152 | 154 | 155 | 156 | 157 | 158 | 159 | 3 171 | 172 | 173 | 174 | 175 | 176 | 177 | 3 196 | 197 | 198 | 199 | 200 | 225 | -------------------------------------------------------------------------------- /cards-svg/9S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 9 102 | 103 | 104 | 105 | 113 | 9 133 | 134 | 135 | 199 | -------------------------------------------------------------------------------- /cards-svg/4C.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 116 | 119 | 123 | 126 | 128 | 129 | 130 | 131 | 132 | 134 | 135 | 136 | 138 | 139 | 140 | 143 | 145 | 146 | 147 | 148 | 149 | 152 | 154 | 155 | 156 | 157 | 158 | 159 | 4 171 | 172 | 173 | 174 | 175 | 176 | 177 | 4 196 | 197 | 198 | 199 | 200 | 231 | -------------------------------------------------------------------------------- /cards-svg/5C.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 116 | 119 | 123 | 126 | 128 | 129 | 130 | 131 | 132 | 134 | 135 | 136 | 138 | 139 | 140 | 143 | 145 | 146 | 147 | 148 | 149 | 152 | 154 | 155 | 156 | 157 | 158 | 159 | 5 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 5 197 | 198 | 199 | 200 | 201 | 202 | 239 | -------------------------------------------------------------------------------- /cards-svg/Joker1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | J 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 117 | 118 | o 130 | 131 | 132 | 133 | k 145 | 146 | 147 | 148 | e 160 | 161 | 162 | 163 | r 175 | 176 | 177 | 178 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | J 221 | 222 | o 235 | 236 | k 249 | 250 | e 263 | 264 | r 277 | 278 | 279 | -------------------------------------------------------------------------------- /cards-svg/6C.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 116 | 119 | 123 | 126 | 128 | 129 | 130 | 131 | 132 | 134 | 135 | 136 | 138 | 139 | 140 | 143 | 145 | 146 | 147 | 148 | 149 | 152 | 154 | 155 | 156 | 157 | 158 | 159 | 6 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 6 197 | 198 | 199 | 200 | 201 | 202 | 245 | -------------------------------------------------------------------------------- /cards-svg/2H.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 194 | 197 | 201 | 204 | 206 | 207 | 208 | 209 | 210 | 212 | 213 | 214 | 216 | 217 | 218 | 221 | 223 | 224 | 225 | 226 | 227 | 230 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 2 252 | 253 | 254 | 255 | 256 | 257 | 258 | 2 279 | 280 | 281 | 282 | 283 | 284 | 309 | -------------------------------------------------------------------------------- /cards-svg/10S.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | 1 102 | 103 | 104 | 105 | 106 | 114 | 122 | 123 | 124 | 0 205 | 1 218 | 0 230 | 231 | -------------------------------------------------------------------------------- /cards-svg/AC.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 146 | 149 | 153 | 156 | 158 | 159 | 160 | 161 | 162 | 164 | 165 | 166 | 168 | 169 | 170 | 173 | 175 | 176 | 177 | 178 | 179 | 182 | 184 | 185 | 186 | 187 | 188 | 189 | A 201 | 202 | 203 | A 252 | 259 | -------------------------------------------------------------------------------- /cards-svg/Joker2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 47 | 50 | 54 | 57 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 74 | 76 | 77 | 78 | 79 | 80 | 83 | 85 | 86 | 87 | 88 | 89 | 90 | J 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 118 | 119 | o 131 | 132 | 133 | 134 | 135 | k 147 | 148 | 149 | 150 | 151 | e 163 | 164 | 165 | 166 | 167 | r 179 | 180 | 181 | 182 | 183 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | J 226 | 227 | 228 | o 241 | 242 | 243 | k 256 | 257 | 258 | e 271 | 272 | 273 | r 286 | 287 | 288 | 289 | -------------------------------------------------------------------------------- /cards-svg/3H.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 194 | 197 | 201 | 204 | 206 | 207 | 208 | 209 | 210 | 212 | 213 | 214 | 216 | 217 | 218 | 221 | 223 | 224 | 225 | 226 | 227 | 230 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 3 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 3 280 | 281 | 282 | 283 | 284 | 285 | 286 | 319 | -------------------------------------------------------------------------------- /cards-svg/7C.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 116 | 119 | 123 | 126 | 128 | 129 | 130 | 131 | 132 | 134 | 135 | 136 | 138 | 139 | 140 | 143 | 145 | 146 | 147 | 148 | 149 | 152 | 154 | 155 | 156 | 157 | 158 | 159 | 7 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 7 198 | 199 | 200 | 201 | 202 | 203 | 204 | 253 | -------------------------------------------------------------------------------- /cards-svg/2D.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 208 | 211 | 215 | 218 | 220 | 221 | 222 | 223 | 224 | 226 | 227 | 228 | 230 | 231 | 232 | 235 | 237 | 238 | 239 | 240 | 241 | 244 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 2 266 | 267 | 268 | 269 | 270 | 271 | 272 | 2 285 | 286 | 287 | 288 | 289 | 290 | 319 | --------------------------------------------------------------------------------