-
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
Reusing an image binary data when multiple copies exists #1153
Comments
Bump |
I would really appriciate it when someone wants to look at this and can propose a complete solution. Am I the only one who wants to add a company logo on every sheet? |
Why you aren't use the HeaderFooter functions? |
Thanks for the respons. It still would be a workaround instead of a fix for this bug in de code. My solution above seems to work in my case but might cause some side effects since I'm not familiair with the whole code and details of image handling in xlsx files. |
Yes, I experience the same issue a fix would be greatly appreciated |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This is far from stale ... still waiting for someone to check and improve my proposal ... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This is far from stale ... still waiting for someone to check and improve my proposal ... please? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
There was activity 18 days ago :-| ... it's not stale unstill it is solved. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Darn it ... cannot leave this thread alone for a few days. |
Can this be opened again? It's not solved and still an issue. |
That helped me, thanks! @MAKS-dev maybe post a PR with your solution? |
@robertpustulka glad it helped and thanks for your reply. Sorry, I'm not experienced with git and github and don't know how this works. Also I don't think this is a 100% perfect solution, but don't know the whole image handling code. |
Fixed by PR 2416. |
This is:
This is a hint for solving #543
What is the expected behavior?
When the same image binary is reused in a workbook, it should only be added once in the actual file. Just like Excel does.
What is the current behavior?
Every copy in the workbook will add its own binary data in the file. The creates very large files.
What are the steps to reproduce?
Use PhpSpreadsheet to open and save the attached file: test-in.xlsx
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue:
(sorry; it does rely on an external Excel file)
You'll notice that the new file has increased roughly 2x the image size.
A check with WinRAR shows 3 copies of the file.
Which versions of PhpSpreadsheet and PHP are affected?
Version 1.8.2 on PHP 7.1.25
Hints for reusing the images
When only loading an Excel file, modifying it without touching the images, and saving it, the code below can be a quick-and-dirty fix:
Add the following in class PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing
Add the following in class PhpOffice\PhpSpreadsheet\Worksheet\Drawing
in function setPath just before the
return
When opening a file, this will reuse the same image index for images with the same name and thus end up with one image binary in the saved file.
Note that this is just a hint for a possible solution. Someone who is more at home in this code should make a better solution.
But since the old issue was reported 14 months ago and closed (even although someone else reported that he could reproduce it), I hope that this time it will stay open untill a full solution is presented.
(as a side note ... I have added a workaround for another issue which is loosly related, see last comment on: #544 - in case anyone tries to save a file with the same name as it was opened)
The text was updated successfully, but these errors were encountered: