Skip to content

Commit

Permalink
Convert icon to RGB mode before conversion
Browse files Browse the repository at this point in the history
Some JPEG files appear to use a non-RGB mode, causing a crash when
trying to save the image without converting it first.

Also default to using the original icon if it can't be resized for some
reason.

Fixes #246
  • Loading branch information
Matoking committed Sep 4, 2023
1 parent 52e780b commit 52e6e31
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Fixed
- Fix crash caused by custom app icons with non-RGB mode

## [1.10.4] - 2023-08-26
### Fixed
- Fix crash caused by the Steam shortcut configuration file containing extra data after the VDF section
Expand Down
13 changes: 10 additions & 3 deletions src/protontricks/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,16 @@ def _get_appid2icon(steam_apps, steam_path):
"App icon %s has unusual size, resizing",
original_icon_path
)
resized_img = img.resize(APP_ICON_SIZE)
resized_img.save(icon_cache_path)
final_icon_path = icon_cache_path
try:
resized_img = img.resize(APP_ICON_SIZE).convert("RGB")
resized_img.save(icon_cache_path)
final_icon_path = icon_cache_path
except Exception:
logger.warning(
"Could not resize %s, ignoring",
original_icon_path,
exc_info=True
)

appid2icon[app.appid] = final_icon_path

Expand Down

0 comments on commit 52e6e31

Please sign in to comment.