Draft
Fix aspect ratio preservation when creating folder icons from non-square images#9
Conversation
Co-authored-by: moxwel <49621788+moxwel@users.noreply.github.com>
Co-authored-by: moxwel <49621788+moxwel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Image don't preserve aspect ratio in icon
Fix aspect ratio preservation when creating folder icons from non-square images
Jul 2, 2025
Owner
|
ImageMagick 7 uses "truecoloralpha" instead of "truecolormatte". |
Co-authored-by: moxwel <49621788+moxwel@users.noreply.github.com>
Author
Fixed both issues in commit 508eac8:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using non-square images (like 350x80), the folder icon generation would stretch them to fit exact square dimensions, causing visual distortion. Circles became ovals, text appeared compressed, and the overall quality was poor.
Example of the issue:

Solution
Fixed the
prepareLabelfunction insrc/image.pyto preserve aspect ratio when resizing images. Changed fromresize(width, height)which stretches images to exact dimensions, totransform(resize='WxH')which preserves aspect ratio while fitting within target dimensions.Code changes (5 lines):
Results
✅ Horizontal images: Aspect ratio preserved correctly
✅ Vertical images: Aspect ratio preserved correctly
✅ Square images: Continue to work perfectly
✅ Extreme ratios: Handled gracefully (e.g., 10x200 → 1px width when needed)
✅ All icon sizes: 10px, 16px, and 135px variants all working properly
✅ Shadow effects: Work correctly with preserved aspect ratios
Visual demonstration:

The fix is minimal and surgical - only changes the resize method calls without affecting other functionality. No existing behavior is broken, and the change maintains backward compatibility.
Fixes #7.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.