Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: custom media sizes #1

Merged
merged 12 commits into from
Nov 8, 2024
Merged

Feature: custom media sizes #1

merged 12 commits into from
Nov 8, 2024

Conversation

Lenochxd
Copy link
Contributor

@Lenochxd Lenochxd commented Nov 8, 2024

Add dynamic resizing for game icons and banners


GET api.nlib.cc/nx/[tid]/icon/[width]/[height]

Returns the game icon. If width and height are not specified, the default size of 1024x1024 JPEG is returned.

GET api.nlib.cc/nx/[tid]/banner/[width]/[height]

Returns the game banner. Supported sizes are 1920x1080 and 1280x720. You can also use /banner/720p or /banner/1080p. If neither width nor height is specified, the default size of 1920x1080 JPEG is returned.

Files that require special permissions, such as those in ".github" or "tests/" directories, are usually not necessary for the update.
- Integrated `resize_image` function to dynamically resize game icons based on request parameters.
- Updated `get_game_icon` function to use the resized image path.
- Modified the `get_nx` endpoint to handle width and height parameters for icon requests.
- Updated readme
- Moved `nearest_size` function utilization to ensure width and height are valid sizes before resizing.
- Added headers to the response for icon requests to include content type, width, height, and filename.
- Updated imports to include `nearest_size` in `main.py`.
Raised HTTP 422 error if width or height are not valid integers.
- Added support for custom banner dimensions in the `/banner` endpoint.
- Updated `resize_image` function to handle default banner sizes and maintain aspect ratio.
- Modified `get_game_banner` to use the resized image path.
- Updated README to reflect changes in banner endpoint usage.
- Corrected the error message for invalid width values in the banner endpoint.
- Removed debug print statements.
- Added a check to raise an HTTP 422 error if the resolution is not accepted instead of 'banner not found'.
@Lenochxd Lenochxd self-assigned this Nov 8, 2024
Updated `get_game_icon` and `get_game_banner` functions to return None if the requested resolution is not supported.
@Lenochxd Lenochxd merged commit 28c4afa into main Nov 8, 2024
1 check passed
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.

1 participant