[GH-ISSUE #514] Cropping Image Changes Transparent Background To Solid Color #794

Closed
opened 2026-03-15 15:30:52 +03:00 by kerem · 10 comments
Owner

Originally created by @Jim-Webfox on GitHub (Sep 26, 2024).
Original GitHub issue: https://github.com/flyimg/flyimg/issues/514

Originally assigned to: @sadok-f on GitHub.

When taking an image with a transparent background, after resizing, cropping and setting output to png, a solid background is added to the image, it is no longer transparent.

Failing Result
https://demo.flyimg.io/upload/w_100,h_50,c_1,o_png/https://brandslogos.com/wp-content/uploads/images/large/laravel-logo-1.png

The image should maintain its transparent background.

image

Originally created by @Jim-Webfox on GitHub (Sep 26, 2024). Original GitHub issue: https://github.com/flyimg/flyimg/issues/514 Originally assigned to: @sadok-f on GitHub. When taking an image with a transparent background, after resizing, cropping and setting output to png, a solid background is added to the image, it is no longer transparent. Failing Result https://demo.flyimg.io/upload/w_100,h_50,c_1,o_png/https://brandslogos.com/wp-content/uploads/images/large/laravel-logo-1.png The image should maintain its transparent background. ![image](https://github.com/user-attachments/assets/76a14def-e6a9-40bd-862f-530be970849b)
kerem 2026-03-15 15:30:52 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sadok-f commented on GitHub (Sep 26, 2024):

Hi @Jim-Webfox ,
Thank you for opening this issue!

Yes, it seems the crop option adds a black background to the generated image.
I'll check it and I'll keep you updated.

<!-- gh-comment-id:2376065979 --> @sadok-f commented on GitHub (Sep 26, 2024): Hi @Jim-Webfox , Thank you for opening this issue! Yes, it seems the crop option adds a black background to the generated image. I'll check it and I'll keep you updated.
Author
Owner

@sadok-f commented on GitHub (Sep 26, 2024):

@Jim-Webfox can you try again? I've deployed a new version with a potential fix.
since we're using the extent option to match the desired size given, we need to add -background none to remove the added background (black in your case).

<!-- gh-comment-id:2376085655 --> @sadok-f commented on GitHub (Sep 26, 2024): @Jim-Webfox can you try again? I've deployed a new version with a potential fix. since we're using the `extent` option to match the desired size given, we need to add `-background none` to remove the added background (black in your case).
Author
Owner

@Jim-Webfox commented on GitHub (Sep 26, 2024):

@sadok-f Thanks for jumping on this so quickly!

It appears that its still happening. The link I provided in the initial issue still shows this, unless its using an old version of flyimg on the demo site?

<!-- gh-comment-id:2377978784 --> @Jim-Webfox commented on GitHub (Sep 26, 2024): @sadok-f Thanks for jumping on this so quickly! It appears that its still happening. The link I provided in the initial issue still shows this, unless its using an old version of flyimg on the demo site?
Author
Owner

@sadok-f commented on GitHub (Sep 26, 2024):

Actually if you add the refresh option you'll get a new generated image rf_1 and the older image should be replaced by the new one, which is not the case here.
I need to look into this issue as well

<!-- gh-comment-id:2377989707 --> @sadok-f commented on GitHub (Sep 26, 2024): Actually if you add the refresh option you'll get a new generated image `rf_1` and the older image should be replaced by the new one, which is not the case here. I need to look into this issue as well
Author
Owner

@Jim-Webfox commented on GitHub (Sep 26, 2024):

Ah good to know in future!

<!-- gh-comment-id:2377995735 --> @Jim-Webfox commented on GitHub (Sep 26, 2024): Ah good to know in future!
Author
Owner

@sadok-f commented on GitHub (Sep 26, 2024):

I think I know what is happening, its not a bug.

Recently we started running the demo page on a docker swarm cluster, where the nodes are not sharing the cache nor the generated images folders.

So the rf_1 option should hit all of the nodes to get the refreshed generated image.

<!-- gh-comment-id:2377996365 --> @sadok-f commented on GitHub (Sep 26, 2024): I think I know what is happening, its not a bug. Recently we started running the demo page on a docker swarm cluster, where the nodes are not sharing the cache nor the generated images folders. So the rf_1 option should hit all of the nodes to get the refreshed generated image.
Author
Owner
<!-- gh-comment-id:2377996510 --> @Jim-Webfox commented on GitHub (Sep 26, 2024): It Works! https://demo.flyimg.io/upload/w_100,h_50,c_1,r_1,o_png/https://brandslogos.com/wp-content/uploads/images/large/laravel-logo-1.png
Author
Owner

@Jim-Webfox commented on GitHub (Sep 26, 2024):

Oh its rf_1 not r_1?

<!-- gh-comment-id:2377997036 --> @Jim-Webfox commented on GitHub (Sep 26, 2024): Oh its rf_1 not r_1?
Author
Owner
<!-- gh-comment-id:2377997746 --> @Jim-Webfox commented on GitHub (Sep 26, 2024): ah still works https://demo.flyimg.io/upload/w_100,h_50,c_1,rf_1,o_png/https://brandslogos.com/wp-content/uploads/images/large/laravel-logo-1.png
Author
Owner

@Jim-Webfox commented on GitHub (Sep 26, 2024):

Im happy, if your happy also we can close this issue.

Thank you

<!-- gh-comment-id:2378007882 --> @Jim-Webfox commented on GitHub (Sep 26, 2024): Im happy, if your happy also we can close this issue. Thank you
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/flyimg#794
No description provided.