Skip to content

Commit

Permalink
Merge pull request #131 from googlefonts/partition-1
Browse files Browse the repository at this point in the history
Fix github actions image generation
  • Loading branch information
m4rc1e committed Feb 15, 2024
2 parents 7b12de4 + 6e984a7 commit 7986b84
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/diffenator2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
logger.setLevel(logging.INFO)


MAX_STYLES = 4
MAX_STYLES = 1
THRESHOLD = 0.90 # Percent difference
NINJA_BUILD_FILE = "build.ninja"

Expand Down
6 changes: 3 additions & 3 deletions src/diffenator2/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import shutil
import tempfile
import sys
import time


class ScreenShotter:
Expand Down Expand Up @@ -62,7 +63,6 @@ def take_gif(self, url: str, dst_dir: str, font_toggle):
if not os.path.exists(after_fp):
os.mkdir(after_fp)

import time
time.sleep(1)
self.take_png(url, before_fp)
time.sleep(1)
Expand All @@ -77,7 +77,7 @@ def set_width(self, width: int):
def _get_browsers(self):
"""Determine which browsers we can screenshot which exist on the system"""
# We can add more webdrivers if needed. Let's focus on these first
supported = ["Chrome", "Firefox", "Safari"]
supported = ["Chrome", "Firefox"]
has = []
driver = webdriver
for browser in supported:
Expand All @@ -100,7 +100,7 @@ def _get_browsers(self):
browser_driver = getattr(driver, browser)(options=options)
else:
browser_driver = getattr(driver, browser)()
browser_driver.set_page_load_timeout(180)
browser_driver.set_page_load_timeout(30)
has.append(browser_driver)
except:
pass
Expand Down
5 changes: 5 additions & 0 deletions src/diffenator2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ def gen_gifs(dir1: str, dir2: str, dst_dir: str):

def gen_gif(img_a_path: str, img_b_path: str, dst: str):
with Image.open(img_a_path) as img_a, Image.open(img_b_path) as img_b:
# Images must have same dimensions in order for PIL to gen gif
# 4-tuple defining the left, upper, right, and lower
crop_box = (0, 0, min(img_a.width, img_b.width), min(img_a.height, img_b.height))
img_a = img_a.crop(crop_box)
img_b = img_b.crop(crop_box)
img_a.save(dst, save_all=True, append_images=[img_b], loop=10000, duration=1000)


Expand Down

0 comments on commit 7986b84

Please sign in to comment.