-
Notifications
You must be signed in to change notification settings - Fork 79
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
save_as_image() as jpeg leads to entirely black image #381
Comments
related to:
This is not something that I can fix.
If the need is to display flextable in github dark mode, you can use a dark theme or create your own (see I am going to add details in the manual of |
Thanks for your answer David! I really appreciate it (and I will never stop praising your package too 😅). I have a few more questions though.
To be clear, the example I provided outputs a fully black image even when not hosted on GitHub. Like literally opening the image in an image viewer, it is all black. Is that expected?
Note: I'm afraid using a dark theme for the flextable would not be a universal solution as people browsing GitHub on light theme will not see it correctly. So I suppose the trick to edit the images manually in an image processor software to fill their background is still the best workaround. |
To me, this is transparent: This is how it looks on my mac. I am done with screenshot now. So your issue is about having a white background! Use the following code before starting any flextable production set_flextable_defaults(background.color = "white") See https://ardata-fr.github.io/flextable-book/format.html#default-formatting-properties
Q:
Yes! Software often add black or gray background. Watch the screenshot above and note I change this background color. My mac display it with gray bg. I don't know what to answer to Q3 and Q4. What do you want to know by asking these questions? If jpeg should be removed as option? That saving to jpeg has no sense? |
(I'm sorry I wasn't more clear earlier, in my previous code examples, I was saving as jpeg, not png, whereas I see in your example that you are saving as png. Your screenshots make sense to be transparent since they are png. I think the issue was saving as jpeg WHILE having a transparent background led to a fully black image. Changing the background to white first did solve the issue!) And oh wow! Yes! You are right,
is exactly what I was looking for! When saving as png, it is now perfect (when saved as jpeg it does work as well and we can see the table clearly, but it also adds a large black border, though it doesn't matter since I prefer saving as png anyway). Hopefully, this thread and solution will be useful to future readers encountering this issue. Thanks so much! You really did think of everything, it never ceases to amaze me :D Thanks so much for your patience with us all while you've put such a tremendous amount of work into perfecting this amazing package and documentation 🙏 PS: I have recently migrated my custom garage functions into a personal package, is there a proper way to let you know that your package is being integrated into other packages and show appreciation? Like dropping this info here as a sidenote, or is it better practice to open a new issue, email you, or message you through your website, or is there already another sort of system in place? |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary. |
I noticed that per default, saving as
png
withsave_as_image
makes the table have a transparent background, so when checked on GitHub with dark mode, it is really difficult to read it:So I tried saving as
jpeg
instead, as those should have an actual non-transparent background. To my surprise, the backgrounds were instead all black! I've tried with the basic example provided in?save_as_image
with the same result. Demo:I've also tried using
webshot2
as well for thepng
(it doesn't supportjpeg
) but it didn't change the problematic transparent backgrounds.Current workaround is to manually fill background with white in an image processing software for each image before pushing to GitHub.
sessionInfo
The text was updated successfully, but these errors were encountered: