alcyone-fig-qa 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alcyone_fig_qa-0.1.0/LICENSE +3 -0
- alcyone_fig_qa-0.1.0/PKG-INFO +47 -0
- alcyone_fig_qa-0.1.0/README.md +26 -0
- alcyone_fig_qa-0.1.0/pyproject.toml +40 -0
- alcyone_fig_qa-0.1.0/setup.cfg +4 -0
- alcyone_fig_qa-0.1.0/src/alcyone_fig_qa/__init__.py +6 -0
- alcyone_fig_qa-0.1.0/src/alcyone_fig_qa/cli.py +171 -0
- alcyone_fig_qa-0.1.0/src/alcyone_fig_qa.egg-info/PKG-INFO +47 -0
- alcyone_fig_qa-0.1.0/src/alcyone_fig_qa.egg-info/SOURCES.txt +11 -0
- alcyone_fig_qa-0.1.0/src/alcyone_fig_qa.egg-info/dependency_links.txt +1 -0
- alcyone_fig_qa-0.1.0/src/alcyone_fig_qa.egg-info/entry_points.txt +2 -0
- alcyone_fig_qa-0.1.0/src/alcyone_fig_qa.egg-info/top_level.txt +1 -0
- alcyone_fig_qa-0.1.0/tests/test_fig_qa.py +49 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: alcyone-fig-qa
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Zero-dependency CLI to calibrate journal print font sizes (>=7 pt), check PNG effective DPI (>=300), and catch Type 3 bitmap fonts in PDF figures.
|
|
5
|
+
Author-email: Alcyone <alcyonecraft@users.noreply.github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://alcyonecraft.github.io/tools.html
|
|
8
|
+
Project-URL: Repository, https://github.com/alcyonecraft/alcyone-fig-qa
|
|
9
|
+
Project-URL: Issues, https://github.com/alcyonecraft/alcyone-fig-qa/issues
|
|
10
|
+
Project-URL: Publication Figure Kit, https://alcyonecraft.gumroad.com/l/publication-figure-kit?utm_source=pypi&utm_medium=sidebar&utm_campaign=alcyone_fig_qa
|
|
11
|
+
Project-URL: Complete Suite, https://alcyonecraft.gumroad.com/l/complete-researcher-suite?utm_source=pypi&utm_medium=sidebar&utm_campaign=alcyone_fig_qa
|
|
12
|
+
Project-URL: YouTube Demo, https://youtube.com/shorts/x0oXsX5kI7I
|
|
13
|
+
Keywords: matplotlib,ggplot2,scientific-figures,peer-review,data-visualization,pdf,dpi,typography,publication,cli
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# alcyone-fig-qa
|
|
23
|
+
|
|
24
|
+
[](https://pypi.org/project/alcyone-fig-qa/)
|
|
25
|
+
[](https://github.com/alcyonecraft/alcyone-fig-qa/blob/main/LICENSE)
|
|
26
|
+
|
|
27
|
+
Zero-dependency scientific figure QA CLI for two-column journals:
|
|
28
|
+
- **Font Calibration (`calc`)**: Compute exact Matplotlib `rcParams` (`pdf.fonttype=42`, Arial/Helvetica) and R `ggplot2` sizes so scaled two-column PDFs stay `>= 7 pt` in print.
|
|
29
|
+
- **Asset Audit (`audit`)**: Verify PNG pixel dimensions & effective DPI at target column width (`>= 300 DPI`) and detect bitmap `/Subtype /Type3` fonts inside exported `.pdf` figures before peer review.
|
|
30
|
+
|
|
31
|
+
- **20-Second Walkthrough (YouTube Shorts)**: https://youtube.com/shorts/x0oXsX5kI7I
|
|
32
|
+
- **Interactive Browser Calibrator**: https://alcyonecraft.github.io/tools.html?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
33
|
+
- **MIT Figure Starter**: https://github.com/alcyonecraft/publication-figure-starter
|
|
34
|
+
- **Full 8-Template Python Figure Kit (`LAUNCH20` for 20% off)**: https://alcyonecraft.gumroad.com/l/publication-figure-kit?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
35
|
+
- **Alcyone Complete Researcher Suite (7-in-1 · $69 · `LAUNCH20` for 20% off)**: https://alcyonecraft.gumroad.com/l/complete-researcher-suite?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
36
|
+
|
|
37
|
+
## Install & Run
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install alcyone-fig-qa
|
|
41
|
+
|
|
42
|
+
# 1. Calibrate Matplotlib/ggplot2 font sizes for Nature/Lancet 7.20 in double column
|
|
43
|
+
alcyone-fig-qa calc --journal nature-double --canvas-in 9.6
|
|
44
|
+
|
|
45
|
+
# 2. Audit exported PNG & PDF figures before journal submission
|
|
46
|
+
alcyone-fig-qa audit figure1.pdf figure1.png --target-width-in 7.2 --strict
|
|
47
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# alcyone-fig-qa
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/alcyone-fig-qa/)
|
|
4
|
+
[](https://github.com/alcyonecraft/alcyone-fig-qa/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
Zero-dependency scientific figure QA CLI for two-column journals:
|
|
7
|
+
- **Font Calibration (`calc`)**: Compute exact Matplotlib `rcParams` (`pdf.fonttype=42`, Arial/Helvetica) and R `ggplot2` sizes so scaled two-column PDFs stay `>= 7 pt` in print.
|
|
8
|
+
- **Asset Audit (`audit`)**: Verify PNG pixel dimensions & effective DPI at target column width (`>= 300 DPI`) and detect bitmap `/Subtype /Type3` fonts inside exported `.pdf` figures before peer review.
|
|
9
|
+
|
|
10
|
+
- **20-Second Walkthrough (YouTube Shorts)**: https://youtube.com/shorts/x0oXsX5kI7I
|
|
11
|
+
- **Interactive Browser Calibrator**: https://alcyonecraft.github.io/tools.html?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
12
|
+
- **MIT Figure Starter**: https://github.com/alcyonecraft/publication-figure-starter
|
|
13
|
+
- **Full 8-Template Python Figure Kit (`LAUNCH20` for 20% off)**: https://alcyonecraft.gumroad.com/l/publication-figure-kit?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
14
|
+
- **Alcyone Complete Researcher Suite (7-in-1 · $69 · `LAUNCH20` for 20% off)**: https://alcyonecraft.gumroad.com/l/complete-researcher-suite?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
15
|
+
|
|
16
|
+
## Install & Run
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install alcyone-fig-qa
|
|
20
|
+
|
|
21
|
+
# 1. Calibrate Matplotlib/ggplot2 font sizes for Nature/Lancet 7.20 in double column
|
|
22
|
+
alcyone-fig-qa calc --journal nature-double --canvas-in 9.6
|
|
23
|
+
|
|
24
|
+
# 2. Audit exported PNG & PDF figures before journal submission
|
|
25
|
+
alcyone-fig-qa audit figure1.pdf figure1.png --target-width-in 7.2 --strict
|
|
26
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "alcyone-fig-qa"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Zero-dependency CLI to calibrate journal print font sizes (>=7 pt), check PNG effective DPI (>=300), and catch Type 3 bitmap fonts in PDF figures."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{name = "Alcyone", email = "alcyonecraft@users.noreply.github.com"}]
|
|
13
|
+
keywords = [
|
|
14
|
+
"matplotlib",
|
|
15
|
+
"ggplot2",
|
|
16
|
+
"scientific-figures",
|
|
17
|
+
"peer-review",
|
|
18
|
+
"data-visualization",
|
|
19
|
+
"pdf",
|
|
20
|
+
"dpi",
|
|
21
|
+
"typography",
|
|
22
|
+
"publication",
|
|
23
|
+
"cli",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Topic :: Scientific/Engineering",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
alcyone-fig-qa = "alcyone_fig_qa.cli:main"
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://alcyonecraft.github.io/tools.html"
|
|
36
|
+
Repository = "https://github.com/alcyonecraft/alcyone-fig-qa"
|
|
37
|
+
Issues = "https://github.com/alcyonecraft/alcyone-fig-qa/issues"
|
|
38
|
+
"Publication Figure Kit" = "https://alcyonecraft.gumroad.com/l/publication-figure-kit?utm_source=pypi&utm_medium=sidebar&utm_campaign=alcyone_fig_qa"
|
|
39
|
+
"Complete Suite" = "https://alcyonecraft.gumroad.com/l/complete-researcher-suite?utm_source=pypi&utm_medium=sidebar&utm_campaign=alcyone_fig_qa"
|
|
40
|
+
"YouTube Demo" = "https://youtube.com/shorts/x0oXsX5kI7I"
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"""Deterministic journal figure font-size calibration and PNG/PDF asset QA."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import re
|
|
7
|
+
import struct
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
JOURNAL_WIDTHS_IN = {
|
|
12
|
+
"nature-double": 7.20,
|
|
13
|
+
"ieee-double": 7.16,
|
|
14
|
+
"a4-full": 6.50,
|
|
15
|
+
"single": 3.50,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
MEDIABOX_RE = re.compile(
|
|
19
|
+
rb"/MediaBox\s*\[\s*(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)\s*\]"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def calibrate_fonts(target_width_in: float, canvas_in: float = 9.6, min_print_pt: float = 7.0) -> dict[str, float]:
|
|
24
|
+
"""Return canvas font sizes calibrated so printed text meets min_print_pt."""
|
|
25
|
+
if target_width_in <= 0 or canvas_in <= 0 or min_print_pt <= 0:
|
|
26
|
+
raise ValueError("Dimensions and font size floor must be positive.")
|
|
27
|
+
scale = target_width_in / canvas_in
|
|
28
|
+
tick_pt = round(max(10.0, min_print_pt / scale), 1)
|
|
29
|
+
base_pt = round(max(tick_pt + 0.5, 10.5), 1)
|
|
30
|
+
axis_pt = round(max(base_pt + 0.7, 11.2), 1)
|
|
31
|
+
panel_pt = round(max(axis_pt + 3.8, 15.0), 1)
|
|
32
|
+
return {
|
|
33
|
+
"scale": round(scale, 3),
|
|
34
|
+
"target_width_in": round(target_width_in, 2),
|
|
35
|
+
"canvas_in": round(canvas_in, 2),
|
|
36
|
+
"min_print_pt": round(min_print_pt, 1),
|
|
37
|
+
"tick_pt": tick_pt,
|
|
38
|
+
"base_pt": base_pt,
|
|
39
|
+
"axis_pt": axis_pt,
|
|
40
|
+
"panel_pt": panel_pt,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def inspect_png(path: Path, target_width_in: float | None = None, min_dpi: int = 300) -> dict[str, object]:
|
|
45
|
+
"""Read PNG IHDR dimensions and optional pHYs DPI metadata."""
|
|
46
|
+
raw = path.read_bytes()
|
|
47
|
+
if not raw.startswith(b"\x89PNG\r\n\x1a\n") or len(raw) < 33:
|
|
48
|
+
return {"ok": False, "issues": ["Invalid PNG signature or truncated header."]}
|
|
49
|
+
ihdr_len, ihdr_type = struct.unpack(">I4s", raw[8:16])
|
|
50
|
+
if ihdr_type != b"IHDR" or ihdr_len < 13:
|
|
51
|
+
return {"ok": False, "issues": ["Missing IHDR chunk."]}
|
|
52
|
+
width_px, height_px = struct.unpack(">II", raw[16:24])
|
|
53
|
+
|
|
54
|
+
declared_dpi: float | None = None
|
|
55
|
+
pos = 8
|
|
56
|
+
while pos + 8 <= len(raw):
|
|
57
|
+
chunk_len, chunk_type = struct.unpack(">I4s", raw[pos : pos + 8])
|
|
58
|
+
data_start = pos + 8
|
|
59
|
+
data_end = data_start + chunk_len
|
|
60
|
+
if data_end + 4 > len(raw):
|
|
61
|
+
break
|
|
62
|
+
if chunk_type == b"pHYs" and chunk_len == 9:
|
|
63
|
+
ppu_x, _ppu_y, unit = struct.unpack(">IIB", raw[data_start:data_end])
|
|
64
|
+
if unit == 1 and ppu_x > 0:
|
|
65
|
+
declared_dpi = round(ppu_x * 0.0254, 1)
|
|
66
|
+
break
|
|
67
|
+
if chunk_type == b"IEND":
|
|
68
|
+
break
|
|
69
|
+
pos = data_end + 4
|
|
70
|
+
|
|
71
|
+
issues: list[str] = []
|
|
72
|
+
effective_dpi = round(width_px / target_width_in, 1) if target_width_in and target_width_in > 0 else None
|
|
73
|
+
if declared_dpi is not None and declared_dpi < min_dpi:
|
|
74
|
+
issues.append(f"Declared pHYs DPI {declared_dpi} is below {min_dpi} DPI.")
|
|
75
|
+
if effective_dpi is not None and effective_dpi < min_dpi:
|
|
76
|
+
issues.append(f"Effective DPI {effective_dpi} at {target_width_in} in is below {min_dpi} DPI.")
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
"ok": len(issues) == 0,
|
|
80
|
+
"format": "PNG",
|
|
81
|
+
"width_px": width_px,
|
|
82
|
+
"height_px": height_px,
|
|
83
|
+
"declared_dpi": declared_dpi,
|
|
84
|
+
"effective_dpi": effective_dpi,
|
|
85
|
+
"issues": issues,
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def inspect_pdf(path: Path) -> dict[str, object]:
|
|
90
|
+
"""Scan PDF bytes for MediaBox size and Type3 bitmap vs TrueType/CID vector fonts."""
|
|
91
|
+
raw = path.read_bytes()
|
|
92
|
+
if not raw.startswith(b"%PDF-"):
|
|
93
|
+
return {"ok": False, "issues": ["Invalid PDF header."]}
|
|
94
|
+
type3_count = len(re.findall(rb"/Subtype\s*/Type3\b", raw))
|
|
95
|
+
vector_count = len(re.findall(rb"/Subtype\s*/(?:TrueType|CIDFontType2|Type1|Type0)\b", raw))
|
|
96
|
+
size_in: tuple[float, float] | None = None
|
|
97
|
+
m = MEDIABOX_RE.search(raw)
|
|
98
|
+
if m:
|
|
99
|
+
x0, y0, x1, y1 = (float(g) for g in m.groups())
|
|
100
|
+
size_in = (round(abs(x1 - x0) / 72.0, 2), round(abs(y1 - y0) / 72.0, 2))
|
|
101
|
+
|
|
102
|
+
issues: list[str] = []
|
|
103
|
+
if type3_count > 0:
|
|
104
|
+
issues.append(f"Detected {type3_count} Type 3 bitmap font(s); set pdf.fonttype=42 in Matplotlib.")
|
|
105
|
+
return {
|
|
106
|
+
"ok": len(issues) == 0,
|
|
107
|
+
"format": "PDF",
|
|
108
|
+
"size_in": size_in,
|
|
109
|
+
"type3_fonts": type3_count,
|
|
110
|
+
"vector_fonts": vector_count,
|
|
111
|
+
"issues": issues,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def audit_file(path: Path, target_width_in: float | None = None, min_dpi: int = 300) -> dict[str, object]:
|
|
116
|
+
"""Audit a PNG or PDF figure file."""
|
|
117
|
+
suffix = path.suffix.lower()
|
|
118
|
+
if suffix == ".png":
|
|
119
|
+
return inspect_png(path, target_width_in=target_width_in, min_dpi=min_dpi)
|
|
120
|
+
if suffix == ".pdf":
|
|
121
|
+
return inspect_pdf(path)
|
|
122
|
+
return {"ok": False, "format": suffix or "unknown", "issues": [f"Unsupported file extension: {path.suffix}"]}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def main(argv: list[str] | None = None) -> int:
|
|
126
|
+
parser = argparse.ArgumentParser(prog="alcyone-fig-qa", description="Journal figure font calibration and PNG/PDF QA.")
|
|
127
|
+
sub = parser.add_subparsers(dest="cmd", required=True)
|
|
128
|
+
|
|
129
|
+
p_calc = sub.add_parser("calc", help="Compute >=7 pt calibrated canvas font sizes and Matplotlib/ggplot2 snippets.")
|
|
130
|
+
p_calc.add_argument("--journal", choices=sorted(JOURNAL_WIDTHS_IN), default="nature-double")
|
|
131
|
+
p_calc.add_argument("--canvas-in", type=float, default=9.6)
|
|
132
|
+
p_calc.add_argument("--min-pt", type=float, default=7.0)
|
|
133
|
+
|
|
134
|
+
p_audit = sub.add_parser("audit", help="Inspect PNG DPI and PDF font embedding (TrueType vs Type3).")
|
|
135
|
+
p_audit.add_argument("files", nargs="+", help="PNG or PDF figure files to audit")
|
|
136
|
+
p_audit.add_argument("--target-width-in", type=float, default=7.2, help="Target print width in inches for effective DPI")
|
|
137
|
+
p_audit.add_argument("--min-dpi", type=int, default=300)
|
|
138
|
+
p_audit.add_argument("--strict", action="store_true", help="Exit 1 if any QA issue is found")
|
|
139
|
+
|
|
140
|
+
args = parser.parse_args(argv)
|
|
141
|
+
if args.cmd == "calc":
|
|
142
|
+
res = calibrate_fonts(JOURNAL_WIDTHS_IN[args.journal], canvas_in=args.canvas_in, min_print_pt=args.min_pt)
|
|
143
|
+
print(
|
|
144
|
+
f"Journal preset: {args.journal} ({res['target_width_in']} in) | "
|
|
145
|
+
f"Canvas: {res['canvas_in']} in | Scale: {res['scale']}x | Print floor >= {res['min_print_pt']} pt"
|
|
146
|
+
)
|
|
147
|
+
print(
|
|
148
|
+
f"matplotlib.rcParams: pdf.fonttype=42, font.family='sans-serif', "
|
|
149
|
+
f"font.size={res['base_pt']}, axes.labelsize={res['axis_pt']}, "
|
|
150
|
+
f"xtick.labelsize={res['tick_pt']}, ytick.labelsize={res['tick_pt']}, panel_letter={res['panel_pt']}"
|
|
151
|
+
)
|
|
152
|
+
print(f"ggplot2 theme_classic(base_size={res['base_pt']}) | axis.title={res['axis_pt']} | tick={res['tick_pt']}")
|
|
153
|
+
return 0
|
|
154
|
+
|
|
155
|
+
any_issue = False
|
|
156
|
+
for raw_path in args.files:
|
|
157
|
+
p = Path(raw_path)
|
|
158
|
+
if not p.is_file():
|
|
159
|
+
print(f"MISSING {p}", file=sys.stderr)
|
|
160
|
+
any_issue = True
|
|
161
|
+
continue
|
|
162
|
+
report = audit_file(p, target_width_in=args.target_width_in, min_dpi=args.min_dpi)
|
|
163
|
+
status = "PASS" if report.get("ok") else "FAIL"
|
|
164
|
+
print(f"[{status}] {p.name}: {report}")
|
|
165
|
+
if not report.get("ok"):
|
|
166
|
+
any_issue = True
|
|
167
|
+
return 1 if (args.strict and any_issue) else 0
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
if __name__ == "__main__":
|
|
171
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: alcyone-fig-qa
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Zero-dependency CLI to calibrate journal print font sizes (>=7 pt), check PNG effective DPI (>=300), and catch Type 3 bitmap fonts in PDF figures.
|
|
5
|
+
Author-email: Alcyone <alcyonecraft@users.noreply.github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://alcyonecraft.github.io/tools.html
|
|
8
|
+
Project-URL: Repository, https://github.com/alcyonecraft/alcyone-fig-qa
|
|
9
|
+
Project-URL: Issues, https://github.com/alcyonecraft/alcyone-fig-qa/issues
|
|
10
|
+
Project-URL: Publication Figure Kit, https://alcyonecraft.gumroad.com/l/publication-figure-kit?utm_source=pypi&utm_medium=sidebar&utm_campaign=alcyone_fig_qa
|
|
11
|
+
Project-URL: Complete Suite, https://alcyonecraft.gumroad.com/l/complete-researcher-suite?utm_source=pypi&utm_medium=sidebar&utm_campaign=alcyone_fig_qa
|
|
12
|
+
Project-URL: YouTube Demo, https://youtube.com/shorts/x0oXsX5kI7I
|
|
13
|
+
Keywords: matplotlib,ggplot2,scientific-figures,peer-review,data-visualization,pdf,dpi,typography,publication,cli
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# alcyone-fig-qa
|
|
23
|
+
|
|
24
|
+
[](https://pypi.org/project/alcyone-fig-qa/)
|
|
25
|
+
[](https://github.com/alcyonecraft/alcyone-fig-qa/blob/main/LICENSE)
|
|
26
|
+
|
|
27
|
+
Zero-dependency scientific figure QA CLI for two-column journals:
|
|
28
|
+
- **Font Calibration (`calc`)**: Compute exact Matplotlib `rcParams` (`pdf.fonttype=42`, Arial/Helvetica) and R `ggplot2` sizes so scaled two-column PDFs stay `>= 7 pt` in print.
|
|
29
|
+
- **Asset Audit (`audit`)**: Verify PNG pixel dimensions & effective DPI at target column width (`>= 300 DPI`) and detect bitmap `/Subtype /Type3` fonts inside exported `.pdf` figures before peer review.
|
|
30
|
+
|
|
31
|
+
- **20-Second Walkthrough (YouTube Shorts)**: https://youtube.com/shorts/x0oXsX5kI7I
|
|
32
|
+
- **Interactive Browser Calibrator**: https://alcyonecraft.github.io/tools.html?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
33
|
+
- **MIT Figure Starter**: https://github.com/alcyonecraft/publication-figure-starter
|
|
34
|
+
- **Full 8-Template Python Figure Kit (`LAUNCH20` for 20% off)**: https://alcyonecraft.gumroad.com/l/publication-figure-kit?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
35
|
+
- **Alcyone Complete Researcher Suite (7-in-1 · $69 · `LAUNCH20` for 20% off)**: https://alcyonecraft.gumroad.com/l/complete-researcher-suite?utm_source=pypi&utm_medium=readme&utm_campaign=alcyone_fig_qa
|
|
36
|
+
|
|
37
|
+
## Install & Run
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install alcyone-fig-qa
|
|
41
|
+
|
|
42
|
+
# 1. Calibrate Matplotlib/ggplot2 font sizes for Nature/Lancet 7.20 in double column
|
|
43
|
+
alcyone-fig-qa calc --journal nature-double --canvas-in 9.6
|
|
44
|
+
|
|
45
|
+
# 2. Audit exported PNG & PDF figures before journal submission
|
|
46
|
+
alcyone-fig-qa audit figure1.pdf figure1.png --target-width-in 7.2 --strict
|
|
47
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/alcyone_fig_qa/__init__.py
|
|
5
|
+
src/alcyone_fig_qa/cli.py
|
|
6
|
+
src/alcyone_fig_qa.egg-info/PKG-INFO
|
|
7
|
+
src/alcyone_fig_qa.egg-info/SOURCES.txt
|
|
8
|
+
src/alcyone_fig_qa.egg-info/dependency_links.txt
|
|
9
|
+
src/alcyone_fig_qa.egg-info/entry_points.txt
|
|
10
|
+
src/alcyone_fig_qa.egg-info/top_level.txt
|
|
11
|
+
tests/test_fig_qa.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
alcyone_fig_qa
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import struct
|
|
2
|
+
import tempfile
|
|
3
|
+
import unittest
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from alcyone_fig_qa.cli import audit_file, calibrate_fonts, main
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def make_png(width: int, height: int, dpi: int | None = None) -> bytes:
|
|
10
|
+
def chunk(tag: bytes, data: bytes) -> bytes:
|
|
11
|
+
return struct.pack(">I", len(data)) + tag + data + b"\x00\x00\x00\x00"
|
|
12
|
+
|
|
13
|
+
ihdr = struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0)
|
|
14
|
+
parts = [b"\x89PNG\r\n\x1a\n", chunk(b"IHDR", ihdr)]
|
|
15
|
+
if dpi is not None:
|
|
16
|
+
ppu = round(dpi / 0.0254)
|
|
17
|
+
parts.append(chunk(b"pHYs", struct.pack(">IIB", ppu, ppu, 1)))
|
|
18
|
+
parts.append(chunk(b"IEND", b""))
|
|
19
|
+
return b"".join(parts)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class FigQATests(unittest.TestCase):
|
|
23
|
+
def test_calibrate_fonts_floor(self) -> None:
|
|
24
|
+
res = calibrate_fonts(target_width_in=7.2, canvas_in=9.6, min_print_pt=7.0)
|
|
25
|
+
self.assertGreaterEqual(res["tick_pt"] * res["scale"], 6.9)
|
|
26
|
+
self.assertEqual(res["panel_pt"], 15.0)
|
|
27
|
+
|
|
28
|
+
def test_png_and_pdf_audit(self) -> None:
|
|
29
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
30
|
+
t = Path(tmp)
|
|
31
|
+
good_png = t / "good.png"
|
|
32
|
+
good_png.write_bytes(make_png(2880, 1800, dpi=400))
|
|
33
|
+
bad_png = t / "low.png"
|
|
34
|
+
bad_png.write_bytes(make_png(800, 600, dpi=96))
|
|
35
|
+
good_pdf = t / "good.pdf"
|
|
36
|
+
good_pdf.write_bytes(b"%PDF-1.4\n/MediaBox [0 0 691.2 432.0]\n/Subtype /TrueType\n%%EOF")
|
|
37
|
+
bad_pdf = t / "type3.pdf"
|
|
38
|
+
bad_pdf.write_bytes(b"%PDF-1.4\n/MediaBox [0 0 691.2 432.0]\n/Subtype /Type3\n%%EOF")
|
|
39
|
+
|
|
40
|
+
self.assertTrue(audit_file(good_png, target_width_in=7.2)["ok"])
|
|
41
|
+
self.assertFalse(audit_file(bad_png, target_width_in=7.2)["ok"])
|
|
42
|
+
self.assertTrue(audit_file(good_pdf)["ok"])
|
|
43
|
+
self.assertFalse(audit_file(bad_pdf)["ok"])
|
|
44
|
+
self.assertEqual(main(["audit", str(bad_pdf), "--strict"]), 1)
|
|
45
|
+
self.assertEqual(main(["audit", str(good_pdf), "--strict"]), 0)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
unittest.main()
|