diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..9d57e76 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,23 @@ +# Contributing to Ithaca Transit Backend +👍🎉 First off, congrats on getting put on this pod 😂🎉👍 + +The following is a set of guidelines for contributing to our backend. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. + +# Versioning +This is _extremely_ important as handling our backend can get quite messy. + +# Making PRs +We want our PRs to be concise but informative. Some pointers as per our PR template: +### Title +Summarize what changes you've made in one sentence. For example: "Exclude staff from the check for follows". For stacked PRs, please indicate clearly in the title where in the stack you are. For example: "[Eatery Refactor][4/5] Converted all files to MVP model." +### Overview +Summarize generally what the purpose of this PR is. +### Changes +Include details of what your changes actually are and how it is intended to work. +### Test Coverage +Describe how you tested this feature: manual testing and/or unit testing. Please include repro steps and/or how to turn the feature on if applicable. In the context of this repo, add a plan for how you intend to test on [integration](https://github.com/cuappdev/integration), with your newly created issue linked. +### Next Steps +If this applies, describe how you plan on addressing future PRs if this is a part of a multi-PR change. +### Related PRs or Issues +If this applies, list related PRs against other branches or repositories. + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..a2b0719 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +## Overview + + +## Changes Made + + +## Test Coverage + + +## Next Steps + + +## Related PRs or Issues + + +## Screenshots + \ No newline at end of file diff --git a/src/utils/helpers.py b/src/utils/helpers.py index e69de29..657bd17 100644 --- a/src/utils/helpers.py +++ b/src/utils/helpers.py @@ -0,0 +1,33 @@ +import requests +from PIL import Image +from io import BytesIO +from collections import Counter + +BASE_URL = "https://dxbhsrqyrr690.cloudfront.net/sidearm.nextgen.sites/cornellbigred.com" + +def get_dominant_color(relative_path, white_threshold=200, black_threshold=50): + image_url = f"{BASE_URL}{relative_path}" + + response = requests.get(image_url) + image = Image.open(BytesIO(response.content)).convert("RGBA") + + image = image.resize((50, 50)) + image = image.quantize(colors=5).convert("RGBA") + pixels = image.getdata() + + filtered_pixels = [ + pixel for pixel in pixels + if not (pixel[0] > white_threshold and pixel[1] > white_threshold and pixel[2] > white_threshold) and + not (pixel[0] < black_threshold and pixel[1] < black_threshold and pixel[2] < black_threshold) + ] + + if filtered_pixels: + pixel_count = Counter(filtered_pixels) + dominant_color = pixel_count.most_common(1)[0][0] + else: + dominant_color = (0, 0, 0) + + return dominant_color + +dominant_color = get_dominant_color('/images/logos/Princeton_Tigers.png?width=80&height=80&mode=max') +print(f"Dominant color: {dominant_color}") \ No newline at end of file