Skip to content

Compare features added by other fork#6

Open
Rustymage wants to merge 20 commits into
Rustymage:ebrock_fork_comparefrom
ebrock:main
Open

Compare features added by other fork#6
Rustymage wants to merge 20 commits into
Rustymage:ebrock_fork_comparefrom
ebrock:main

Conversation

@Rustymage
Copy link
Copy Markdown
Owner

No description provided.

Rustymage and others added 20 commits November 19, 2024 07:19
* License Removal

* License Update

MIT License Added

* READ.md updated

Installation instructions added

* READ.md Updates

osx_services & font titles added

* README.md Updated

Font section created and updated

* README.md

Bullet point added

* README.md Updated

osx_services updated

* Update README.md

Link added to Robot font and removal of Avenir (licensed font)

* Font Removal

Removal of Avenir font as it's a paid font.

* Update to README.md

Link fixed

* Update README.md

* Resolving Comment on PR

Resolving stevequinn#8 (comment)

* Font Arg Parse

* PR 8 Update

Utilised CoPilot to add argument for font name changes

* PR8 Font Validation

Validate font using CoPilot help

* Update to files

.gitignore & READ.md update

* Remove Test Image

* Comments

Re-added comments deleted

* .

* Validation Check

Improvement in check

* Validation Check

Correction to duplication of error messages.

* - Streamlines error reporting
- Removes redundant code

* - Adds python logging instead of print statements.

---------

Co-authored-by: Steve Quinn <steve@sq.net.au>
* - Adds support for parameterised font style variants.

* - Updates readme param instructions.

* Logging Update

Removed milli seconds and function name from logging to improve readability

---------

Co-authored-by: Anthony <19926955+Rustymage@users.noreply.github.com>
Introduces a --palette-tolerance argument to control color grouping for palette extraction. Enhances palette.py to filter near-white colors and allows dynamic tolerance, improving palette accuracy and customization.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the photo-border CLI with more presentation controls: configurable fonts/font variants, alternate EXIF text layouts, palette filtering/tolerance, and optional Fuji film-simulation extraction/rendering. It also updates supporting docs/tests and some repository metadata.

Changes:

  • Add configurable font selection/variant handling and new EXIF rendering options, including single-line/two-line layouts and Fuji film-simulation support.
  • Update palette extraction to filter near-white colors and expose palette tolerance as a CLI option.
  • Refresh docs/tests/repo metadata, including README usage, a new font-related test, license text, and ignore rules.

Reviewed changes

Copilot reviewed 9 out of 12 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
text.py Adds font-variant discovery/validation helpers and updates font creation/sizing APIs.
tests/test_text.py Adds a basic test around loading font variants.
tests/test_exif.py Removes trailing blank lines only.
tests/__init__.py Empty package marker; no substantive change shown.
palette.py Adds near-white filtering and tolerance-aware palette extraction.
main.py Extends the CLI, logging, font handling, film-sim processing, and palette placement flow.
fonts/Avenir.ttc Binary font asset listed in the PR; no textual diff was available to inspect.
exif.py Adds lens-name shortening and exiftool-based film-simulation extraction.
border.py Refactors EXIF layout rendering and adds film-simulation icon lookup/loading.
README.md Updates installation/usage/testing documentation.
LICENSE Replaces the license text with MIT license content.
.gitignore Expands ignored generated/media/font-related paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_text.py
Comment on lines +14 to +22
variants = []

try:
font = create_font(size=12, fontpath=font_path, index=index)
except Exception:
variants = load_font_variants(fontpath=font_path)
print(f'Error loading {fontname} font variant {index}. Available variants: {variants}')
assert len(variants) is not 0

Comment thread border.py
Comment on lines +310 to +314
# If palette is present, adjust text position to leave room on the right
# Palette width is approximately border.bottom / 3 * number_of_colors (up to 5 colors)
# We'll reserve space for the palette on the right side
if has_palette:
palette_reserved_width = border.bottom # Approximate palette width plus padding
Comment thread README.md

## osx_services

Adds quick actions to you OSX menu for quick deployment of tool.
Comment thread border.py
from enum import Enum
from dataclasses import dataclass
import glob
import numpy as np
Comment thread main.py
Comment on lines +51 to +54
parser.add_argument('--oneline', action='store_true', default=False,
help='Use single-line text layout for large, polaroid, and instagram borders')
parser.add_argument('--twoline', action='store_true', default=False,
help='Use two-line left-aligned layout for large, polaroid, and instagram borders')
Comment thread text.py
Comment on lines +22 to +31
while True:
try:
font = ImageFont.truetype(fontpath, size=12, index=index)
info = {
'family': font.getname()[0],
'style': font.getname()[1]
}
variants.append((index, info))
index += 1
except Exception:
Comment thread README.md
Comment on lines 25 to +44
```bash
usage: python main.py [-h] [-e] [-p] [-t{s,m,l,p,i}] filename
usage: python main.py [-h] [-e] [-p] [-f] [-fb] [-t{s,m,l,p,i}] filename

Add a border and exif data to a jpg or png photo

positional arguments:
filename

options:
-h, --help show this help message and exit
-e, --exif print photo exif data on the border
-p, --palette Add colour palette to the photo border
-t, --border_type Border Type: p for polaroid, s for small, m for medium, l for large, i for instagram (default: s)
--include File patterns to include (default: *.jpg *.jpeg *.png, *.JPG, *.JPEG, *.PNG)
--exclude File patterns to exclude (default: *_border*)
-h, --help Show this help message and exit
-e, --exif Print photo exif data on the border
-p, --palette Add colour palette to the photo border
-t, --border_type Border Type: p for polaroid, s for small, m for medium, l for large, i for instagram (default: s)
-f, --font Font Typeface to use (default: Roboto-Regular.ttf)
-fv, --fontvariant Font style variant to use (default: 0)
-fb, --fontbold Bold Font Typeface to use (default: Roboto-Medium.ttf)
-fbv, --fontboldvariant Bold Font style variant to use (default: 0)
--include File patterns to include (default: *.jpg *.jpeg *.png, *.JPG, *.JPEG, *.PNG)
--exclude File patterns to exclude (default: *_border*)

Comment thread tests/test_text.py
except Exception:
variants = load_font_variants(fontpath=font_path)
print(f'Error loading {fontname} font variant {index}. Available variants: {variants}')
assert len(variants) is not 0
Comment thread border.py
Optional[Image.Image]: The matched film simulation image, or None if not found
"""
film_sim_images = {}
sim_image_files = glob.glob('fuji-sims/*.png')
Comment thread border.py
Comment on lines +390 to +404
film_sim_images = {}
sim_image_files = glob.glob('fuji-sims/*.png')
for filepath in sim_image_files:
sim_name = os.path.splitext(os.path.basename(filepath))[0]
film_sim_images[sim_name] = Image.open(filepath)

# Normalize the target film sim name for matching
# Convert to lowercase and replace spaces with underscores
normalized_target = film_sim.lower().replace(' ', '_')

for image_key in film_sim_images:
normalized_key = image_key.lower()
# Check for exact match or substring match
if normalized_target == normalized_key or normalized_target in normalized_key:
return film_sim_images[image_key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants