mkgallery 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.
Files changed (48) hide show
  1. mkgallery-0.1.0/.github/dependabot.yml +13 -0
  2. mkgallery-0.1.0/.github/workflows/release.yml +96 -0
  3. mkgallery-0.1.0/.gitignore +10 -0
  4. mkgallery-0.1.0/LICENSE.txt +133 -0
  5. mkgallery-0.1.0/PKG-INFO +89 -0
  6. mkgallery-0.1.0/README.md +70 -0
  7. mkgallery-0.1.0/docs/superpowers/plans/2026-10-04-mkgallery.md +2260 -0
  8. mkgallery-0.1.0/docs/superpowers/specs/2026-10-04-mkgallery-design.md +123 -0
  9. mkgallery-0.1.0/pyproject.toml +61 -0
  10. mkgallery-0.1.0/src/mkgallery/__about__.py +24 -0
  11. mkgallery-0.1.0/src/mkgallery/__init__.py +1 -0
  12. mkgallery-0.1.0/src/mkgallery/analyze.py +133 -0
  13. mkgallery-0.1.0/src/mkgallery/build.py +86 -0
  14. mkgallery-0.1.0/src/mkgallery/cache.py +77 -0
  15. mkgallery-0.1.0/src/mkgallery/cli.py +100 -0
  16. mkgallery-0.1.0/src/mkgallery/errors.py +2 -0
  17. mkgallery-0.1.0/src/mkgallery/exif.py +56 -0
  18. mkgallery-0.1.0/src/mkgallery/imaging.py +55 -0
  19. mkgallery-0.1.0/src/mkgallery/model.py +19 -0
  20. mkgallery-0.1.0/src/mkgallery/render.py +135 -0
  21. mkgallery-0.1.0/src/mkgallery/scan.py +22 -0
  22. mkgallery-0.1.0/src/mkgallery/select.py +264 -0
  23. mkgallery-0.1.0/src/mkgallery/templates/page.html.j2 +86 -0
  24. mkgallery-0.1.0/src/mkgallery/vendor/VERSIONS.md +21 -0
  25. mkgallery-0.1.0/src/mkgallery/vendor/glightbox/LICENSE.md +21 -0
  26. mkgallery-0.1.0/src/mkgallery/vendor/glightbox/glightbox.min.css +1 -0
  27. mkgallery-0.1.0/src/mkgallery/vendor/glightbox/glightbox.min.js +2 -0
  28. mkgallery-0.1.0/src/mkgallery/vendor/jquery/LICENSE.txt +20 -0
  29. mkgallery-0.1.0/src/mkgallery/vendor/jquery/jquery.min.js +2 -0
  30. mkgallery-0.1.0/src/mkgallery/vendor/justifiedgallery/LICENSE +22 -0
  31. mkgallery-0.1.0/src/mkgallery/vendor/justifiedgallery/jquery.justifiedGallery.min.js +8 -0
  32. mkgallery-0.1.0/src/mkgallery/vendor/justifiedgallery/justifiedGallery.min.css +110 -0
  33. mkgallery-0.1.0/tests/__init__.py +0 -0
  34. mkgallery-0.1.0/tests/conftest.py +50 -0
  35. mkgallery-0.1.0/tests/test_analyze.py +69 -0
  36. mkgallery-0.1.0/tests/test_cache.py +44 -0
  37. mkgallery-0.1.0/tests/test_cli.py +126 -0
  38. mkgallery-0.1.0/tests/test_exif.py +37 -0
  39. mkgallery-0.1.0/tests/test_hardening.py +105 -0
  40. mkgallery-0.1.0/tests/test_helpers.py +29 -0
  41. mkgallery-0.1.0/tests/test_imaging.py +98 -0
  42. mkgallery-0.1.0/tests/test_metrics.py +40 -0
  43. mkgallery-0.1.0/tests/test_render.py +102 -0
  44. mkgallery-0.1.0/tests/test_scan.py +27 -0
  45. mkgallery-0.1.0/tests/test_select.py +113 -0
  46. mkgallery-0.1.0/tests/test_select_balance.py +119 -0
  47. mkgallery-0.1.0/tests/test_select_filters.py +80 -0
  48. mkgallery-0.1.0/tests/test_vendor.py +33 -0
@@ -0,0 +1,13 @@
1
+ version: 2
2
+ updates:
3
+ # mkgallery is a CLI app (project.scripts), not imported as a library by
4
+ # other projects -- versioning-strategy: increase.
5
+ - package-ecosystem: "pip"
6
+ directory: "/"
7
+ versioning-strategy: increase
8
+ schedule:
9
+ interval: "weekly"
10
+ - package-ecosystem: "github-actions"
11
+ directory: "/"
12
+ schedule:
13
+ interval: "weekly"
@@ -0,0 +1,96 @@
1
+ name: Publish Python ๐Ÿ distribution ๐Ÿ“ฆ to PyPI
2
+ on:
3
+ push:
4
+ tags:
5
+ - "v[0-9]*"
6
+
7
+ jobs:
8
+ test:
9
+ name: Lint and test the code ๐Ÿงช
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ with:
14
+ persist-credentials: false
15
+ fetch-depth: 0 # hatch-vcs needs tags to derive the version
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.x"
20
+ cache: 'pip'
21
+ - name: Install exiftool
22
+ run: sudo apt-get update && sudo apt-get install -y libimage-exiftool-perl
23
+ - name: Install hatch
24
+ run: python -m pip install hatch --user
25
+ - name: Lint
26
+ run: hatch fmt --check
27
+ - name: Type check
28
+ run: hatch run types:check
29
+ - name: Test
30
+ run: hatch test
31
+
32
+ build:
33
+ name: Build distribution ๐Ÿ“ฆ
34
+ runs-on: ubuntu-latest
35
+ needs:
36
+ - test
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+ with:
40
+ persist-credentials: false
41
+ fetch-depth: 0
42
+ - name: Set up Python
43
+ uses: actions/setup-python@v5
44
+ with:
45
+ python-version: "3.x"
46
+ cache: 'pip'
47
+ - name: Install pypa/build
48
+ run: python3 -m pip install build --user
49
+ - name: Build a binary wheel and a source tarball
50
+ run: python3 -m build
51
+ - name: Store the distribution packages
52
+ uses: actions/upload-artifact@v4
53
+ with:
54
+ name: python-package-distributions
55
+ path: dist/
56
+
57
+ publish-to-pypi:
58
+ name: Publish Python ๐Ÿ distribution ๐Ÿ“ฆ to PyPI
59
+ needs:
60
+ - build
61
+ runs-on: ubuntu-latest
62
+ environment:
63
+ name: pypi
64
+ url: https://pypi.org/p/mkgallery
65
+ permissions:
66
+ id-token: write # mandatory for trusted publishing
67
+ steps:
68
+ - name: Download all the dists
69
+ uses: actions/download-artifact@v4
70
+ with:
71
+ name: python-package-distributions
72
+ path: dist/
73
+ - name: Publish distribution ๐Ÿ“ฆ to PyPI
74
+ uses: pypa/gh-action-pypi-publish@release/v1
75
+
76
+ create-release:
77
+ name: Create GitHub Release
78
+ runs-on: ubuntu-latest
79
+ permissions:
80
+ contents: write
81
+ needs:
82
+ - publish-to-pypi
83
+ steps:
84
+ - name: Create GitHub Release (stable)
85
+ uses: softprops/action-gh-release@v2
86
+ if: |
87
+ !contains(github.ref_name, 'a') && !contains(github.ref_name, 'b') && !contains(github.ref_name, 'rc')
88
+ with:
89
+ generate_release_notes: true
90
+ - name: Create GitHub Release (pre-release)
91
+ uses: softprops/action-gh-release@v2
92
+ if: |
93
+ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc')
94
+ with:
95
+ prerelease: true
96
+ generate_release_notes: true
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.egg-info/
3
+ .venv/
4
+ dist/
5
+ build/
6
+ .mypy_cache/
7
+ .ruff_cache/
8
+ .pytest_cache/
9
+ .superpowers/
10
+ src/mkgallery/__about__.py
@@ -0,0 +1,133 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ > Required Notice: Copyright Janna Hopp (https://github.com/bytehexe)
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree
10
+ to them as both strict obligations and conditions to all
11
+ your licenses.
12
+
13
+ ## Copyright License
14
+
15
+ The licensor grants you a copyright license for the
16
+ software to do everything you might do with the software
17
+ that would otherwise infringe the licensor's copyright
18
+ in it for any permitted purpose. However, you may
19
+ only distribute the software according to [Distribution
20
+ License](#distribution-license) and make changes or new works
21
+ based on the software according to [Changes and New Works
22
+ License](#changes-and-new-works-license).
23
+
24
+ ## Distribution License
25
+
26
+ The licensor grants you an additional copyright license
27
+ to distribute copies of the software. Your license
28
+ to distribute covers distributing the software with
29
+ changes and new works permitted by [Changes and New Works
30
+ License](#changes-and-new-works-license).
31
+
32
+ ## Notices
33
+
34
+ You must ensure that anyone who gets a copy of any part of
35
+ the software from you also gets a copy of these terms or the
36
+ URL for them above, as well as copies of any plain-text lines
37
+ beginning with `Required Notice:` that the licensor provided
38
+ with the software. For example:
39
+
40
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
41
+
42
+ ## Changes and New Works License
43
+
44
+ The licensor grants you an additional copyright license to
45
+ make changes and new works based on the software for any
46
+ permitted purpose.
47
+
48
+ ## Patent License
49
+
50
+ The licensor grants you a patent license for the software that
51
+ covers patent claims the licensor can license, or becomes able
52
+ to license, that you would infringe by using the software.
53
+
54
+ ## Noncommercial Purposes
55
+
56
+ Any noncommercial purpose is a permitted purpose.
57
+
58
+ ## Personal Uses
59
+
60
+ Personal use for research, experiment, and testing for
61
+ the benefit of public knowledge, personal study, private
62
+ entertainment, hobby projects, amateur pursuits, or religious
63
+ observance, without any anticipated commercial application,
64
+ is use for a permitted purpose.
65
+
66
+ ## Noncommercial Organizations
67
+
68
+ Use by any charitable organization, educational institution,
69
+ public research organization, public safety or health
70
+ organization, environmental protection organization,
71
+ or government institution is use for a permitted purpose
72
+ regardless of the source of funding or obligations resulting
73
+ from the funding.
74
+
75
+ ## Fair Use
76
+
77
+ You may have "fair use" rights for the software under the
78
+ law. These terms do not limit them.
79
+
80
+ ## No Other Rights
81
+
82
+ These terms do not allow you to sublicense or transfer any of
83
+ your licenses to anyone else, or prevent the licensor from
84
+ granting licenses to anyone else. These terms do not imply
85
+ any other licenses.
86
+
87
+ ## Patent Defense
88
+
89
+ If you make any written claim that the software infringes or
90
+ contributes to infringement of any patent, your patent license
91
+ for the software granted under these terms ends immediately. If
92
+ your company makes such a claim, your patent license ends
93
+ immediately for work on behalf of your company.
94
+
95
+ ## Violations
96
+
97
+ The first time you are notified in writing that you have
98
+ violated any of these terms, or done anything with the software
99
+ not covered by your licenses, your licenses can nonetheless
100
+ continue if you come into full compliance with these terms,
101
+ and take practical steps to correct past violations, within
102
+ 32 days of receiving notice. Otherwise, all your licenses
103
+ end immediately.
104
+
105
+ ## No Liability
106
+
107
+ ***As far as the law allows, the software comes as is, without
108
+ any warranty or condition, and the licensor will not be liable
109
+ to you for any damages arising out of these terms or the use
110
+ or nature of the software, under any kind of legal claim.***
111
+
112
+ ## Definitions
113
+
114
+ The **licensor** is the individual or entity offering these
115
+ terms, and the **software** is the software the licensor makes
116
+ available under these terms.
117
+
118
+ **You** refers to the individual or entity agreeing to these
119
+ terms.
120
+
121
+ **Your company** is any legal entity, sole proprietorship,
122
+ or other kind of organization that you work for, plus all
123
+ organizations that have control over, are under the control of,
124
+ or are under common control with that organization. **Control**
125
+ means ownership of substantially all the assets of an entity,
126
+ or the power to direct its management and policies by vote,
127
+ contract, or otherwise. Control can be direct or indirect.
128
+
129
+ **Your licenses** are all the licenses granted to you for the
130
+ software under these terms.
131
+
132
+ **Use** means anything you do with the software requiring one
133
+ of your licenses.
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.5
2
+ Name: mkgallery
3
+ Version: 0.1.0
4
+ Summary: Summarise a photo collection as a single gallery page
5
+ License-Expression: PolyForm-Noncommercial-1.0.0
6
+ License-File: LICENSE.txt
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: click
9
+ Requires-Dist: imagehash
10
+ Requires-Dist: jinja2
11
+ Requires-Dist: numpy
12
+ Requires-Dist: pillow>=10
13
+ Requires-Dist: platformdirs
14
+ Requires-Dist: pyexiftool
15
+ Requires-Dist: rawpy
16
+ Requires-Dist: scikit-learn
17
+ Requires-Dist: scipy
18
+ Description-Content-Type: text/markdown
19
+
20
+ # mkgallery
21
+
22
+ Summarise a large photo collection โ€” say, a year โ€” as **one static page**: a title and a
23
+ gallery of the most interesting pictures, picked automatically.
24
+
25
+ ```
26
+ mkgallery ~/Photos/2025 --title "2025"
27
+ ```
28
+
29
+ writes `2025.html` and a `2025_assets/` directory next to it. Nothing in the source
30
+ directory is touched, and no configuration is read from it.
31
+
32
+ ## Requirements
33
+
34
+ - Python โ‰ฅ 3.10
35
+ - [`exiftool`](https://exiftool.org/) on `PATH`
36
+ - Formats: JPEG, PNG, WebP, TIFF and RAW (CR2, CR3, NEF, ARW, DNG)
37
+
38
+ ## Install
39
+
40
+ ```
41
+ pipx install . # or: hatch run mkgallery โ€ฆ
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ```
47
+ mkgallery SRC --title TITLE [options]
48
+ ```
49
+
50
+ | Option | Default | |
51
+ |---|---|---|
52
+ | `-t, --title` | required | Page title; also names `TITLE.html` / `TITLE_assets/` |
53
+ | `-n, --count` | 48 | Number of images shown |
54
+ | `-o, --output-dir` | `.` | Where to write the output (must not be inside `SRC`) |
55
+ | `--order` | `chronological` | `chronological`, or `varied` (neighbours are as dissimilar as possible) |
56
+ | `--event-quota / --no-event-quota` | off | Every event (a run of days with photos, gaps over 24 h split events) gets at least one image; the other slots are shared in proportion to the square root of the event size |
57
+ | `--balance` | 1 | 0โ€“1. Down-weights images in crowded regions when clustering: 0 treats every image alike, 1 gives sparse regions the same weight as dense ones |
58
+ | `--cache-dir` | user cache dir | Analysis cache (must not be inside `SRC`) |
59
+ | `--no-cache` | | Do not read or write the cache |
60
+ | `-j, --jobs` | CPU count | Parallel workers |
61
+
62
+ ## How images are chosen
63
+
64
+ The selection is ported from [mkmapdiary](https://github.com/bytehexe/mkmapdiary)'s front page:
65
+
66
+ 1. Each image is analysed from a small preview (for RAW files the embedded JPEG โ€” nothing
67
+ is developed at this stage): sharpness, contrast, entropy, perceptual and colour hashes.
68
+ Results are cached by path, size and modification time.
69
+ 2. Near-duplicates (per day), unusually soft images and flat, low-entropy images are dropped.
70
+ 3. The rest is clustered by colour and capture time into `--count` groups; the sharpest,
71
+ best-contrast image of each group is chosen. The picks therefore spread over the whole
72
+ year and over different looks. With `--event-quota` (off by default) this is done per event,
73
+ so a few photos from a small trip are not lost among thousands from a long holiday.
74
+ 4. Only the chosen images are converted (RAW files are developed here) into a thumbnail and
75
+ a 1600 px version.
76
+
77
+ ## Credits and licences
78
+
79
+ mkgallery is licensed under the [PolyForm Noncommercial License 1.0.0](LICENSE.txt).
80
+
81
+ The generated page bundles these libraries (all MIT licensed). Their licence texts and
82
+ copyright notices are shipped in `TITLE_assets/lib/<name>/` and in
83
+ `src/mkgallery/vendor/`:
84
+
85
+ - [jQuery](https://jquery.com)
86
+ - [Justified Gallery](https://github.com/miromannino/Justified-Gallery) โ€” the row layout
87
+ - [GLightbox](https://github.com/biati-digital/glightbox) โ€” the lightbox
88
+
89
+ The selection approach and metric code are adapted from mkmapdiary (same author).
@@ -0,0 +1,70 @@
1
+ # mkgallery
2
+
3
+ Summarise a large photo collection โ€” say, a year โ€” as **one static page**: a title and a
4
+ gallery of the most interesting pictures, picked automatically.
5
+
6
+ ```
7
+ mkgallery ~/Photos/2025 --title "2025"
8
+ ```
9
+
10
+ writes `2025.html` and a `2025_assets/` directory next to it. Nothing in the source
11
+ directory is touched, and no configuration is read from it.
12
+
13
+ ## Requirements
14
+
15
+ - Python โ‰ฅ 3.10
16
+ - [`exiftool`](https://exiftool.org/) on `PATH`
17
+ - Formats: JPEG, PNG, WebP, TIFF and RAW (CR2, CR3, NEF, ARW, DNG)
18
+
19
+ ## Install
20
+
21
+ ```
22
+ pipx install . # or: hatch run mkgallery โ€ฆ
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```
28
+ mkgallery SRC --title TITLE [options]
29
+ ```
30
+
31
+ | Option | Default | |
32
+ |---|---|---|
33
+ | `-t, --title` | required | Page title; also names `TITLE.html` / `TITLE_assets/` |
34
+ | `-n, --count` | 48 | Number of images shown |
35
+ | `-o, --output-dir` | `.` | Where to write the output (must not be inside `SRC`) |
36
+ | `--order` | `chronological` | `chronological`, or `varied` (neighbours are as dissimilar as possible) |
37
+ | `--event-quota / --no-event-quota` | off | Every event (a run of days with photos, gaps over 24 h split events) gets at least one image; the other slots are shared in proportion to the square root of the event size |
38
+ | `--balance` | 1 | 0โ€“1. Down-weights images in crowded regions when clustering: 0 treats every image alike, 1 gives sparse regions the same weight as dense ones |
39
+ | `--cache-dir` | user cache dir | Analysis cache (must not be inside `SRC`) |
40
+ | `--no-cache` | | Do not read or write the cache |
41
+ | `-j, --jobs` | CPU count | Parallel workers |
42
+
43
+ ## How images are chosen
44
+
45
+ The selection is ported from [mkmapdiary](https://github.com/bytehexe/mkmapdiary)'s front page:
46
+
47
+ 1. Each image is analysed from a small preview (for RAW files the embedded JPEG โ€” nothing
48
+ is developed at this stage): sharpness, contrast, entropy, perceptual and colour hashes.
49
+ Results are cached by path, size and modification time.
50
+ 2. Near-duplicates (per day), unusually soft images and flat, low-entropy images are dropped.
51
+ 3. The rest is clustered by colour and capture time into `--count` groups; the sharpest,
52
+ best-contrast image of each group is chosen. The picks therefore spread over the whole
53
+ year and over different looks. With `--event-quota` (off by default) this is done per event,
54
+ so a few photos from a small trip are not lost among thousands from a long holiday.
55
+ 4. Only the chosen images are converted (RAW files are developed here) into a thumbnail and
56
+ a 1600 px version.
57
+
58
+ ## Credits and licences
59
+
60
+ mkgallery is licensed under the [PolyForm Noncommercial License 1.0.0](LICENSE.txt).
61
+
62
+ The generated page bundles these libraries (all MIT licensed). Their licence texts and
63
+ copyright notices are shipped in `TITLE_assets/lib/<name>/` and in
64
+ `src/mkgallery/vendor/`:
65
+
66
+ - [jQuery](https://jquery.com)
67
+ - [Justified Gallery](https://github.com/miromannino/Justified-Gallery) โ€” the row layout
68
+ - [GLightbox](https://github.com/biati-digital/glightbox) โ€” the lightbox
69
+
70
+ The selection approach and metric code are adapted from mkmapdiary (same author).