Athletics Certificate Generator: General Use Version
appdev ai powershell grpahics certs
In first few versions of the certificate, headings and labels were embedded in the templated background image for the certificates. Powershell then accurately positioned drawstrings to include the competitor’s name below Name label in the image. The same was done for Distance and Time. I this later version, all text was removed from background image and is generated by drawstrings generated from data by Powershell scripts
Links
- GitHub Repository djaus2/AthleticsCertificateMaker
- Sample certificate 004-Fred Nurk.png
- Overview blog post
- Image template generation blog post
- Image Template Generation Appendix
- Sending Certificates and Results
Changes — 19 September 2026
Summary of today’s session on the Aberfeldie Masters Athletics certificate generator.
Repository
- Working with a clone copy in
\AthleticsCertificateMaker, of https://github.com/djaus2/AthleticsCertificateMaker
Certificate text moved from image to scripts
- Heading
- SubHeading
- Host
- Date
Name, Distance and Time Labels had been previously moved.
All text that was previously baked into the certificate template image
is now drawn by the scripts. CertificateTemplate.png is now pure
artwork (frame, singlet, logo) and CertificateTemplateorig.png is kept
untouched as the unmodified master.
| Name | Text | Font | Size | Y |
|---|---|---|---|---|
| Title | 1 HOUR TRACK RUN | Times New Roman Bold | 77 px | 70 |
| SubTitle | Moonee Valley Athletics Centre | Arial Narrow | 51 px | 180 |
| Host | Aberfeldie Masters Athletics | Times New Roman Italic | 38 px | 247 |
| Date | 16 September 2026 | Arial Narrow | 34 px | 312 |
These definitions live in CertificateText.ps1, which both
GenerateCertificates.ps1 and GenerateCertificatesTIME.ps1
dot-source — so the event wording only needs editing in one place. Each
line is drawn centred at its natural width.
The same was done earlier for the field labels: the standard script draws Name/Distance labels above their values, and the TIME script draws Name/Distance/Time label-and-value groups.
Matching the baked fonts
A PNG stores only pixels — there is no font metadata to recover, so the fonts had to be identified by measurement and eyeball:
- Measure the baked glyphs. Each text line’s bounding box was found by scanning the image for the navy text colour, giving the exact pixel width, height and centre of every line.
- Compare candidates by width.
Graphics.MeasureString()was run over likely fonts (Times New Roman, Georgia, Cambria, Garamond, Arial Narrow, etc.) at a known size; the measured width was then scaled to the baked width to estimate the real font size. - Compare letterforms visually. Candidate fonts were rendered side-by-side with the original strip and matched by shape — this is how Arial Narrow (subtitle, date) and Times New Roman italic (host line) were identified.
- Condensation. The baked text is narrower than the same font at
the same height would naturally render — it was horizontally
compressed when the artwork was created. An initial implementation
replicated this with
Graphics.ScaleTransform, but that was dropped in favour of simply sizing each font so its natural width matches — since every line is centred anyway, the squeeze bought nothing but complexity. - DPI pitfall. The template is 192 DPI, so a point-based font
renders twice as large as expected. All drawn text uses
GraphicsUnit.Pixelto avoid the unit conversion entirely.
The result is visually near-identical to the baked version, but the wording, fonts and positions are now all script-controlled — which is what makes the package reusable for a different event.
Other changes
- Startup email-mode check — each script scans its own source to
detect whether
$Mail.Save()and/or$Mail.Send()are enabled: both enabled aborts with an error popup; send-only requires confirmation; save-only proceeds silently; neither warns that no emails will be produced. - Sending account resolution —
$SendUsingAccountis resolved once at startup; if the account isn’t in the Outlook profile a warning is shown and the default account is used, instead of silently assigning null. Applied at every mail site, including the certificate branch ofGenerateCertificates.ps1which previously never set it. clean.ps1rework — emptiesOutput\*,Results\*,logs\*, removes~$*.xlsxlock files and the stray,\folder, while keeping the tracked sample004-Fred Nurk.pngand leaving the folder structure in place.-WhatIfpreviews without deleting.- Outlook requirements documented — classic desktop Outlook with a default mail profile is required; the “New Outlook” app does not support COM automation.
| Topic | Subtopic | |
| < Prev: | Athletics Certificate Generator | Sending Certificates and Results |
| This Category Links | ||
| Category: | Application Dev Index: | Application Dev |