Comments (19)
ah, ok. The whole point of this function though is to provide a way for the user to specify the background color.
So I think we just need to extend it to not only understand #rrggbb
but #rrggbbaa
from timg.
@hzeller thanks for the fix!
Tested it on all the problematic SVG files linked in this issue and timg displays them correctly!
I believe this issue can be closed.
from timg.
Great to hear.
Fix was done by @lromor ; thanks Leonardo!
from timg.
We need to find how we can tell the API to background fill with none
like the convert commandline does.
from timg.
Maybe take a look at how icat does it?
Ignore the scaling issue, icat doesn't properly scale images to the original aspect ratio.
from timg.
Looks like that program is using imlib2 . Can it read SVGs ?
Might be worthwhile experimenting with.
from timg.
Actually did some digging into the timg codebase and honestly its just this fix right here:
Line 44 in 26b58c0
- return {(uint8_t)r, (uint8_t)g, (uint8_t)b, 0xff};
+ return {(uint8_t)r, (uint8_t)g, (uint8_t)b, 0x00};
The only place ParseColor
is used is the following:
Lines 758 to 779 in cfd5f7a
and with the above proposed change we can simplify the logic of this codeblock. For example if we are using a transparent background no need to query the terminal for a background color.
This does remove user specified backgrounds though, since the opacity will always be hardcoded 0, but that can be changed with reading the opacity value properly in the ParseColor
method.
I can make a PR on this soon.
from timg.
Okay so basically I see two things here:
- allow user to specify background opacity (new feature request)
- fix proper use of background color with transparency (bug fix)
from timg.
I do have a solution but currently it is not working with the kitty protocol.
Can you point me to where the color is rendered for kitty?
Edit: found the bug
from timg.
@xeruf For me the resolution was to simply use timg
as follows: timg -b none <filename>
.
the default option -b auto
will try to blend and cause all transparency in the object to be removed, both for PNGs and SVGs.
from timg.
extend it to not only understand #rrggbb but #rrggbbaa
I attempted this however, intermediary opacity values do not work, i.e if aa
is 00
then the background is transparent (same as -b none
) and if aa
is any other value than the background is completely opaque, resulting in the same backgroud as #rrggbb
. Therefore, I believe there would be no point in adding such a feature for users to specify transparent backgrounds via rgba.
I believe this is a non-issue and can be closed or maybe I just don't understand the issue properly.
Unless we want to change the default background option to be -b none
so that transparency is handled by default, instead of blending.
from timg.
@hzeller can you provide comments to this issue?
What are the requirements to close this issue?
from timg.
interestingly, it depends on the SVG - some are rendered transparent, some with white background, even though all are theoretically transparent.
None seems to respect the -b
flag though.
from timg.
None seems to respect the -b flag though.
Can you show an example, as this did work for me.
If you post the actual SVG's which didn't work that would appreciated as well so that we can reproduce the issue.
from timg.
❯ timg --version
timg 1.4.4+ <https://timg.sh/>
Copyright (c) 2016..2021 Henner Zeller. This program is free software; license GPL 2.0.
Image decoding GraphicsMagick 1.3.38 (2022-03-26)
Openslide 3.4.1
Video decoding libav 59.16.100
This always shows a white background:
This never shows a background, regardless of the -b
flag:
from timg.
This always shows a white background:
Can confirm, the svg file always renders a white background. However, when I convert the svg the png using -b none
properly has transparency.
This never shows a background, regardless of the -b flag:
Can also confirm, converting from the svg to the png does give nominal behavior and it is possible to change the background.
Looks like SVG's are just not being read in/operated on properly like png files are.
A temporary solution to this issue is to then convert svg files to png files.
it depends on the SVG
I wonder if the SVG has different specs?
from timg.
If auto
is the problem, then maybe the query for your particular terminal does not work ? What is the terminal you're using ?
from timg.
Other SVG files work on the same terminal. I am using termite.
as far as I'm aware of, transparency doesn't work with auto
anyway, just none
. auto
is not the issue.
from timg.
So, this should work now, can you test on your favorite transparent SVGs ?
from timg.
Related Issues (20)
- carbonyl love?
- Images rendered blurry in fzf preview. HOT 2
- new version not have binary file HOT 7
- No package 'libdeflate' found HOT 2
- ipv4 vs. ipv6 HOT 5
- libsixel is not available on Fedora 38 HOT 2
- Image preview in `lf` HOT 1
- Detected Crash: AddressSanitizer: heap-buffer-overflow HOT 7
- missing size parameter in iterm's protocol HOT 12
- Image viewer with scrolling HOT 3
- Detected memory leaks on timg
- Auto detect for Ghostty doesn't work HOT 8
- Cannot display certain SVG files HOT 6
- can we convert a whole video? HOT 2
- tmux passthrough for other terminals HOT 3
- Cannot read pdf in alpine container HOT 10
- Opensllde Error HOT 5
- Sixel support in foot does not get recongnized correctly HOT 8
- How about implementing [hyperlink support](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) HOT 2
- Displaying long images starting from the top instead of the bottom HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from timg.