Skip to content

Commit

Permalink
Fix a thin line of background showing on the right side (#50)
Browse files Browse the repository at this point in the history
* Fix a thin line of background showing on the right side of contact sheets

If the contact sheet width (minus horizontal spacing) is not evenly divisible
by the number of image columns, a thin line of background is left visible on
the right side after composition.

Fix this by interpreting the value of --width as a target we try to match as
closely as possible, instead of as an unchangable constant.
In the current implementation this is an upper limit.

* Remove dead code

The grid is never set to None, so this check is useless

* Don't pass float dimensions to MediaInfo.desired_size

This should make the calculated frame height match the frame width more closely,
since the final rounding of the width is now preformed before it is used in the
calculation.
  • Loading branch information
LingMan authored and amietn committed Jan 6, 2019
1 parent 5816a45 commit 22ea195
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions vcsi/vcsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ def desired_size(self, width=DEFAULT_CONTACT_SHEET_WIDTH):
Returns (width, height)
"""
ratio = width / float(self.display_width)
desired_height = math.floor(self.display_height * ratio)
return (int(width), int(desired_height))
desired_height = int(math.floor(self.display_height * ratio))
return (width, desired_height)

def parse_attributes(self):
"""Parse multiple media attributes
Expand Down Expand Up @@ -501,10 +501,8 @@ def grid_desired_size(
"""Computes the size of the images placed on a mxn grid with given fixed width.
Returns (width, height)
"""
if grid:
desired_width = (width - (grid.x - 1) * horizontal_margin) / grid.x
else:
desired_width = width
desired_width = (width - (grid.x - 1) * horizontal_margin) / grid.x
desired_width = int(math.floor(desired_width))

return media_info.desired_size(width=desired_width)

Expand Down Expand Up @@ -797,6 +795,7 @@ def compose_contact_sheet(
media_info,
width=args.vcs_width,
horizontal_margin=args.grid_horizontal_spacing)
width = args.grid.x * (desired_size[0] + args.grid_horizontal_spacing) - args.grid_horizontal_spacing
height = args.grid.y * (desired_size[1] + args.grid_vertical_spacing) - args.grid_vertical_spacing

try:
Expand All @@ -818,7 +817,7 @@ def compose_contact_sheet(
media_info,
header_font,
args.metadata_horizontal_margin,
args.vcs_width,
width,
template_path=args.metadata_template_path)

line_spacing_coefficient = 1.2
Expand All @@ -828,7 +827,7 @@ def compose_contact_sheet(
if args.metadata_position == "hidden":
header_height = 0

final_image_width = args.vcs_width
final_image_width = width
final_image_height = height + header_height
transparent = (255, 255, 255, 0)

Expand Down

0 comments on commit 22ea195

Please sign in to comment.