Adds stamp_logo_png() — the raster analogue of civilytics_logo() for outputs that are already rendered to a file rather than held as a ggplot/grob.
civilytics_logo() / make_logo_grob() brand ggplot objects, but flextables and other table outputs are exported to PNG first, so they can't be branded with the existing helpers (they currently get hand-rolled, package-external logo compositing). stamp_logo_png() closes that gap: it resolves the same brand asset that make_logo_grob() selects (same type/variant switch) and composites it into a corner of an existing PNG in place — so file-based tables stay visually consistent with logo-branded plots.
Design
Dependency-free. Uses only png + grid + grDevices, all already in Imports — deliberately no magick dependency for the package.
Preserves the image's pixel dimensions (overwrites in place).
Configurable type (wordmark/mark), variant (light/dark), position (four corners), width_frac, margin_frac. Defaults match civilytics_logo() (wordmark / light / bottom-right).
# Brand a table exported to PNG so it matches civilytics_logo()-branded plotsragg::agg_png("table.png",width=8,height=4,units="in",res=200)plot(flextable::flextable(head(mtcars)))dev.off()stamp_logo_png("table.png")# wordmark, bottom-rightstamp_logo_png("table.png",type="mark",position="bottom-left")
Tests
tests/testthat/test_logo.R (21 assertions): dimension preservation + invisible path return, all 16 type/variant/position combinations run, and input validation (missing file, invalid type). All pass.
Notes
Docs regenerated for this function only (man/stamp_logo_png.Rd + the relevant NAMESPACE exports/imports). I intentionally did not sweep up the pre-existing roxygen drift in master (unrelated .Rd/NAMESPACE churn) to keep this PR focused.
Origin: extracted from the CRDC social-media reporting pipeline, where six branded table chunks each hand-rolled this compositing; this generalizes it into the brand package so any flextable/PNG output can brand consistently.
## Summary
Adds `stamp_logo_png()` — the raster analogue of `civilytics_logo()` for outputs that are already rendered to a file rather than held as a ggplot/grob.
`civilytics_logo()` / `make_logo_grob()` brand ggplot objects, but **flextables and other table outputs are exported to PNG first**, so they can't be branded with the existing helpers (they currently get hand-rolled, package-external logo compositing). `stamp_logo_png()` closes that gap: it resolves the **same brand asset** that `make_logo_grob()` selects (same `type`/`variant` switch) and composites it into a corner of an existing PNG in place — so file-based tables stay visually consistent with logo-branded plots.
## Design
- **Dependency-free.** Uses only `png` + `grid` + `grDevices`, all already in `Imports` — deliberately **no `magick`** dependency for the package.
- Preserves the image's pixel dimensions (overwrites in place).
- Configurable `type` (wordmark/mark), `variant` (light/dark), `position` (four corners), `width_frac`, `margin_frac`. Defaults match `civilytics_logo()` (wordmark / light / bottom-right).
```r
# Brand a table exported to PNG so it matches civilytics_logo()-branded plots
ragg::agg_png("table.png", width = 8, height = 4, units = "in", res = 200)
plot(flextable::flextable(head(mtcars)))
dev.off()
stamp_logo_png("table.png") # wordmark, bottom-right
stamp_logo_png("table.png", type = "mark", position = "bottom-left")
```
## Tests
`tests/testthat/test_logo.R` (21 assertions): dimension preservation + invisible path return, all 16 type/variant/position combinations run, and input validation (missing file, invalid `type`). All pass.
## Notes
- Docs regenerated for this function only (`man/stamp_logo_png.Rd` + the relevant `NAMESPACE` exports/imports). I intentionally did **not** sweep up the pre-existing roxygen drift in `master` (unrelated `.Rd`/`NAMESPACE` churn) to keep this PR focused.
- Origin: extracted from the CRDC social-media reporting pipeline, where six branded table chunks each hand-rolled this compositing; this generalizes it into the brand package so any flextable/PNG output can brand consistently.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
civilytics_logo()/make_logo_grob() brand ggplot/grobs, but flextables and
other outputs are rendered to PNG first and can't use them. stamp_logo_png()
is the raster analogue: it resolves the SAME brand asset that make_logo_grob()
uses (via the type/variant switch) and composites it into a corner of an
existing PNG in place, so file-based tables stay visually consistent with
logo-branded plots.
Dependency-free by design — uses only png + grid + grDevices (all already
imported), no magick. Configurable type/variant/position/width/margin;
preserves the image's pixel dimensions. Adds tests (21 assertions).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Adds
stamp_logo_png()— the raster analogue ofcivilytics_logo()for outputs that are already rendered to a file rather than held as a ggplot/grob.civilytics_logo()/make_logo_grob()brand ggplot objects, but flextables and other table outputs are exported to PNG first, so they can't be branded with the existing helpers (they currently get hand-rolled, package-external logo compositing).stamp_logo_png()closes that gap: it resolves the same brand asset thatmake_logo_grob()selects (sametype/variantswitch) and composites it into a corner of an existing PNG in place — so file-based tables stay visually consistent with logo-branded plots.Design
png+grid+grDevices, all already inImports— deliberately nomagickdependency for the package.type(wordmark/mark),variant(light/dark),position(four corners),width_frac,margin_frac. Defaults matchcivilytics_logo()(wordmark / light / bottom-right).Tests
tests/testthat/test_logo.R(21 assertions): dimension preservation + invisible path return, all 16 type/variant/position combinations run, and input validation (missing file, invalidtype). All pass.Notes
man/stamp_logo_png.Rd+ the relevantNAMESPACEexports/imports). I intentionally did not sweep up the pre-existing roxygen drift inmaster(unrelated.Rd/NAMESPACEchurn) to keep this PR focused.🤖 Generated with Claude Code