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

Black background of PNG images with transparent background in the Wysiwyg editor #3998

Open
boesbo opened this issue May 16, 2024 · 11 comments
Labels

Comments

@boesbo
Copy link
Contributor

boesbo commented May 16, 2024

Preconditions (*)

  1. OpenMage 20.7.0

Steps to reproduce (*)

  1. Open the Static Block creation page
  2. Go to the editor and load an image. A PNG with a transparent background

Expected result (*)

  1. The thumbnail created is with black background instead of transparent
  2. Thumbnail viewable on edit is with black background instead of transparent

Actual result (*)

  1. The problem only affects thumbnail creation and preview display in the editor.
  2. Regarding Thumb creation I am testing a fix that involves adding $image->keepTransparency(true); to line 386 of the file app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php
  3. As for displaying the preview in the editor, go to Controller: app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php Action: directiveAction(). I still haven't found a way to solve it.

I attach images of my GD version.

Thumb app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php::resizeFile

Screen Shot 2024-05-16 at 16 17 21 PM

Preview in editor app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php::directiveAction

Screen Shot 2024-05-16 at 16 17 31 PM

Screen Shot 2024-05-16 at 15 33 36 PM

@boesbo boesbo added the bug label May 16, 2024
@fballiano
Copy link
Contributor

I'm testing this but I don't think it's the editor's fault because I see the black background already right after uploading it

Screenshot 2024-05-17 alle 10 07 53

at that moment I don't think the new wyswyg has nothing to do with it

@boesbo
Copy link
Contributor Author

boesbo commented May 17, 2024

I'm testing this but I don't think it's the editor's fault because I see the black background already right after uploading it

Screenshot 2024-05-17 alle 10 07 53 at that moment I don't think the new wyswyg has nothing to do with it

Yes, the problem is in the two files I mentioned above

@fballiano
Copy link
Contributor

same thing happening with the old editor on latest v19

Screenshot 2024-05-17 alle 10 12 12

@boesbo
Copy link
Contributor Author

boesbo commented May 17, 2024

same thing happening with the old editor on latest v19

Screenshot 2024-05-17 alle 10 12 12

Yes, by selling the history I noticed that it is something that we have been carrying with me I imagine since Magento 1.9. Do you think this is intentional behavior? It seems strange.

@fballiano
Copy link
Contributor

mmmm I really don't know :-\

all images are always re-saved in order to remove any possible form of "virus" within the image, but to remove transparency I've no idea why

@pquerner
Copy link
Contributor

Its imagemagick. Where it gets its settings tho, that I don't know.
I remember something from the TYPO3 days: https://stackoverflow.com/questions/18809692/why-do-imagemagick-based-thumbnail-images-of-pdf-files-in-typo3-have-black-backg https://forge.typo3.org/issues/37060

I dont know if that setting is available to customize from within magento, or if its only sitting in some php.ini file. I know too little about this.

@boesbo
Copy link
Contributor Author

boesbo commented May 17, 2024

Its imagemagick. Where it gets its settings tho, that I don't know. I remember something from the TYPO3 days: https://stackoverflow.com/questions/18809692/why-do-imagemagick-based-thumbnail-images-of-pdf-files-in-typo3-have-black-backg https://forge.typo3.org/issues/37060

I dont know if that setting is available to customize from within magento, or if its only sitting in some php.ini file. I know too little about this.

That part of the script uses the GD library not ImageMagick:
$image = Varien_Image_Adapter::factory('GD2');

@pquerner
Copy link
Contributor

Well this perhaps then
https://stackoverflow.com/questions/5913284/php-gd-transparent-areas-goes-black

(im checking out here, im just googleing stuff anyway)

@boesbo
Copy link
Contributor Author

boesbo commented May 17, 2024

Yes, this is it. In the two files I wrote at the beginning, transparency management is missing. But it's so obvious that it makes me doubt. It doesn't seem like an oversight.

I can also act by creating a PR, but first I want to better understand if this behavior has a purpose, since it is only visible in the editor.

@pquerner
Copy link
Contributor

Well, all this system comes from a time where it wasnt the norm and browsers had troubles with transparent files? I think up to IE11 no IE browser learned to do it or something? So it could be very well just that. :D

@boesbo
Copy link
Contributor Author

boesbo commented May 17, 2024

In the next few days I will propose a patch. I am very clear on the problem. Transparency is simply not managed in the two phases: 1. thumb creation, 2. editor preview url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants