Closed yamsergey closed 5 months ago
The feature to remove the background is not implemented as a command. However, although the code needs to be modified, there is an API to change visibility of background (and other layers). This API is only available for converting to PNG.
It like this:
import supernotelib as sn
from supernotelib.converter import ImageConverter, VisibilityOverlay
file_path = ... # set your note file path
page_number = ... # set page number you want to convert
notebook = sn.load_notebook(file_path)
converter = ImageConverter(notebook)
exclude_bg = ImageConverter.build_visibility_overlay(
background=VisibilityOverlay.INVISIBLE,
main=VisibilityOverlay.DEFAULT,
layer1=VisibilityOverlay.DEFAULT,
layer2=VisibilityOverlay.DEFAULT,
layer3=VisibilityOverlay.DEFAULT)
img = converter.convert(page_number, visibility_overlay=exclude_bg)
img.save('output.png', format='PNG')
If you are in a hurry, try it.
By the way, why do you want the background to be transparent instead of white?
I'm not in hurry at all :) Really enjoy your work actually, if you will consider it as a part of upcoming releases it's fine 👍 I can try to open PR if you don't mind, but it will be not sooner than the next week.
Regarding transparency, sometimes it's useful when you draw something. As a example
Wouldn't it be cool to be able to export it and use it as stickers? :)
It's cool. I added your request to a future release plan.
Sorry for too late. I have just released v0.5.0. It includes an option "--exclude-background" to make background transparent for PNG and SVG. Please try it.
$ supernote-tool convert -a -t png --exclude-background your.note output.png
Hello,
Splendid job!
One question. Is it possible to exclude the background image when the
*.note
file is converted intoSVG, PNG, PDF
? And maybe even make it transparent?