-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Artefacts with transparency in png drawing #3624
Comments
You do not show how you arrived at the value in $stamp_file = file_get_contents('issue.3624.png'); // the file you uploaded above
$stamp = PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::fromString($stamp_file); Or, more simply (use drawing as-is rather than as memory drawing): $stamp = new PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
$stamp->setPath('issue.3624.png'); In either case, the result appears to be exactly the same as if I had added the drawing directly in Excel (adjusting the height appropriately). If your results differ, please show how. |
@oleibman , my attachment isn't original picture, but the broken result Okay, I tested different approaches and looks like found the bug. Lets try these 3 snippents file_get_contents with storage path
Storage getter, that I use. It is almost file_get_contents
Not memory drawing but base
Results: MemoryDrawing is absolutely broken Where is alpha channel? |
Thank you, I am now able to duplicate your problem. However, I believe the problem lies in Php, not in PhpSpreadsheet. $stamp_file = file_get_contents('issue.3624b.png'); // your new image
$gdImage = imagecreatefromstring($stamp_file);
imagepng($gdImage, 'issue.3624c.png'); This code snippet, which does not use PhpSpreadsheet at all, shows that its output file does not match the input file (and, in fact, matches your 'bad' image). When I substitute your original input file, the output file does match it, so I believe this code is correct, and therefore that one or both of the native Php functions |
I have opened an issue with Php. |
Fix PHPOffice#3624. Use the same logic as elsewhere in the same module to invoke `imagesavealpha` when appropriate. (I confess that I do not understand the use case where you would not use imagesavealpha.) The fix was easy; writing a test was not. Google to the rescue.
From the Php issue, an extra call was suggested (imagesavealpha). I will create a PR to incorporate this suggestion into PhpSpreadsheet. Look for it in a day or two. |
Fix #3624. Use the same logic as elsewhere in the same module to invoke `imagesavealpha` when appropriate. (I confess that I do not understand the use case where you would not use imagesavealpha.) The fix was easy; writing a test was not. Google to the rescue.
This is:
What is the expected behavior?
In excel I can insert png image with transparency without problems
What is the current behavior?
Problem is artefacts in transparent background, like in example below. This is one file made from 2 in Photoshop.
Absolutely opaque, with grey zones.
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet 1.28
PHP 8.1
The text was updated successfully, but these errors were encountered: