Fix exif text overlapping color palette on medium border type#3
Merged
Conversation
Agent-Logs-Url: https://github.com/Rustymage/photoborder/sessions/78577cd4-f8d6-4fef-8e79-0cc07f5257cd Co-authored-by: Rustymage <19926955+Rustymage@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix exif data text overlapping with color palette
Fix exif text overlapping color palette on medium border type
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
--exifand--paletteare used together on non-centered border types (small/medium), exif text was drawn without awareness of the palette's horizontal position, causing overlap.Changes
border.pymax_width: int = Noneparameter todraw_exifmax_widthis set and the layout is non-centered, iteratively shrinksfont_sizeandheading_font_sizeuntil all exif text lines fit within the available widthImageFont/ImageDrawimports to module level;ImageDraw.Drawconstructed once outside the shrink loopmain.pypalette_size,palette_x,palette_y) to before the exif drawing stepexif_max_width = palette_x - border.leftand passes it todraw_exifOriginal prompt
Problem
When using
--border_type m(medium) with both--exifand--paletteflags, the exif data text is drawn over the color palette instead of shrinking to fit the available space.Root cause:
draw_exifinborder.pydraws text horizontally (left-to-right) for non-centered border types (small, medium).draw_exifhas no knowledge of how much horizontal space the palette occupies.main.py, the palette is calculated afterdraw_exifis called, so there is no way to pass width constraints to the exif drawing step.Fix
1.
border.py— Addmax_widthparameter todraw_exifAdd an optional
max_widthparameter todraw_exif. When provided (and the layout is non-centered), iteratively reduce the font sizes until all exif text lines fit withinmax_width.2.
main.py— Calculate palette width before callingdraw_exif, passmax_widthexif_max_width = palette_x - border.left(the horizontal space available for text).max_width=exif_max_widthintodraw_exif.overlay_palettecall after exif drawing (order of image compositing unchanged).Files to change
border.py—draw_exiffunction: add optionalmax_widthparameter and font-shrinking loopmain.py—process_imagefunction: move palette size/position calculation before exif drawing, compute and passexif_max_widthThe following is the prior conversation context from the user's chat exploration (may be truncated):
User: when using color palette and exfi environment variables the exif text can overlap with the color palette and should not.
Assistant: PR #2 — Fix exif text overlap with color palette in border has already been merged into
mainabout 13 minutes ago! 🎉Here's a summary of what was implemented:
Changes Made
border.py—draw_exiffunction:max_widthparametermax_widthis provided and the layout is non-centered (small/medium border types), the font sizes are iteratively reduced until all EXIF text lines fit within the available horizontal spacemain.py—process_imagefunction:This pull request was created from Copilot chat.