mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #287] Feature request: Eliminate temporary files from worksheet_insert_image_buffer #229
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#229
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @evanmiller on GitHub (May 6, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/287
Originally assigned to: @jmcnamara on GitHub.
I'd like to create workbooks that potentially contain thousands of small images. These images are generated in memory, and so I'm inserting them into the sheet with
worksheet_insert_image_buffer_opt. However I noticed that this function just writes the buffer to a temporary file and reads it back in.I'd like to avoid creating thousands of temporary files when constructing my spreadsheet. I believe the needed change could be as simple as replacing:
a0e6a362ba/src/worksheet.c (L6306)With:
See the
fmemopen(http://man7.org/linux/man-pages/man3/fmemopen.3.html) - this will create a (second) buffer managed by the file handle that will be freed when the file handle is closed.Happy to open a PR if you think it's worthwhile.
@jmcnamara commented on GitHub (May 6, 2020):
The code should only keep the filehandle open for the duration of the read and parsing of the metadata but maybe you want to avoid even that.
I'd say create a PR anyway, just to see if it passes all the compatibility and other tests.
I think that it probably isn't ANSI-C compatible, which is probably why I didn't use it. If you plug it in and run a build you will soon find out.
I mainly try to maintain ANSI-C compatibility so that the code is consumable by MSVC so it would need to work there as well (or at least with some #define to map it to the equivalent Windows function). I haven't checked but I presume that is possible. Could you check that as well.
@evanmiller commented on GitHub (May 6, 2020):
Okay, opened a pull request with the full rationale, awaiting results from Travis. I would indeed prefer to avoid hitting the file system with every single image, even if the images are immediately deleted.
I'm not sure where to look re: Windows compatibility. It might be worth setting up the project on AppVeyor.
@jmcnamara commented on GitHub (May 6, 2020):
Ok. Understandable. Just in case it is an issue, I should point out that the library uses tmp files for the XML data before assembling the file.
There were AppVeyor and Tea-CI build files but they failed for opaque and inconsistent reasons so I removed them in commit
8abc4ecd19.@jmcnamara commented on GitHub (May 6, 2020):
The builds are failing on Travis due to the ANSI-C issue.
I was a bit surprised that it builds on MacOS (even with gcc-9) but it does.
Anyway, incompatibility with ANSI-C is a deal breaker. I'd suggest:
@evanmiller commented on GitHub (May 6, 2020):
If you're OK with branching on an #ifdef then I will look into getting the compile-time machinery in place. I think we can do this inside the CMakeLists script without adding a user-facing flag.
Might be worth getting a MacOS target going on Travis so that both code branches get exercised.
@jmcnamara commented on GitHub (May 8, 2020):
Merged in PR #288