this post was submitted on 22 Mar 2025
112 points (76.4% liked)

Linux

52350 readers
1051 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

what the heck!! that is so wild, mind blowing, i thought the main difference between raster graphics and vector graphics was the quality but i didn't think about it too deeply.

i had no idea svg files actually used html code and pretty much could be modified using only text and amazing code woa!!! this opens up the possibility for so many things on linux i think.

for example, on a linux distro, we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it.

svg can be given a lot of attributes like movement, mouse hovering, change color, change anything. and most svg files are still under a megabyte. wow.. please let me know other fun facts about svg or eps files. i really like doing graphic design on linux and inkscape.

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 190 points 3 days ago* (last edited 1 day ago) (3 children)

No, SVG files are not HTML.

~~Please change this post title (currently "today i learned: svg files are literally just html code"), to avoid spreading this incorrect factoid!~~

~~I suggest you change it to "today i learned: svg files are just text in an html-like language" or something like that.~~ edit: thanks OP

SVG is a dialect of XML.

XML and HTML have many similarities, because they both are descendants of SGML. But, as others have noted in this thread, HTML is also not XML. (Except for when it's XHTML...)

Like HTML, SVG also can use CSS, and, in some environments (eg, in browsers, but not in Inkscape) also JavaScript. But, the styles you can specify with CSS in SVG are quite different than those you can specify with CSS in HTML.

Lastly, you can embed SVG in HTML and it will work in (modern) browsers. You cannot embed HTML in SVG, however.

[–] [email protected] 8 points 2 days ago (2 children)

I remember when XHTML was supposed to replace HTML. Everything was going to be standardized and web designers would run their HTML code against a validator...it was going to be glorious! And of course it never happened, because demanding that all websites conform to the XHTML standard would've broken a lot of websites.

So, HTML5 ate XHTML's lunch because it was much more forgiving, and...oh yeah, you could watch videos and play games in it, too.

[–] [email protected] 1 points 16 hours ago

Killing Flash was worth it, but couldn't we have avoided its reign of tyranny if we'd just stuck with Java applets in the first place...?

[–] [email protected] 7 points 2 days ago (2 children)

I fucking learned a whole-ass language for nothing back then because I thought it was the future!, fuck you, XHTML!

[–] [email protected] 1 points 16 hours ago

As someone who can find a billion XML parser libraries and, like, three HTML parser libraries, you do have my gratitude if it's worth anything.

[–] [email protected] 4 points 2 days ago

100% of XHTML will work in HTML5.

[–] [email protected] 7 points 3 days ago

You know how they say that the internet is a series of tubes? We used to think that was just a funny old man. Turns out, it is the literal truth. The internet is made up of SVG files!

[–] [email protected] 20 points 3 days ago

ok thank you very much!!

[–] [email protected] 3 points 2 days ago (1 children)

Hold on now. If an svg will render as valid html in browsers, does that mean I can use Inkscape as a wysiwyg webpage editor, and just export that to html?

[–] [email protected] 3 points 2 days ago

good question, i once made a website mockup on inkscape and it would be interesting if i could just turn that into an html file

[–] [email protected] 8 points 3 days ago (1 children)

I don't think it would be lighter, SVGs need a rendering tool to read the code and draw the artwork for the vector based images. This has always been slower than just displaying a bmp, jpg, or PNG.

[–] [email protected] 2 points 3 days ago

It's lighter in memory. on android (development) it has been said for a few years now that it's better to use them for most cases, because android apps tend to use a ton of icons and this way they are small, themable, scaleable (the other option is to include multiple versions with diff resolutions), and can even have animations. it can basically save a lot of space.

but of course that will make no difference when the apps are 180 MB, partly because of the same 30 MB native libs being bundled for 4 different CPU architectures, because wasteful the dev didn't bother to produce different APKs for the different kinds of CPUs. and similar project mismanagement things.

[–] [email protected] 10 points 3 days ago (2 children)

for example, on a linux distro, we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it.

Isn't that how it already works? GNOME system icons are all SVG - that's what allows them to change colors when you change themes or switch between light and dark mode.

[–] [email protected] 5 points 3 days ago

There are both, PNG as standard sizes and the SVGs. I believe the DE pulls the 32 48 256 pixel pngs so no addition rendering is needed.

[–] [email protected] 3 points 3 days ago (1 children)

i didn't know that, is that the same in xfce??

[–] [email protected] 2 points 3 days ago* (last edited 3 days ago)

hard to tell, but you can check it:

find / -type f -name *.svg

maybe also include -xdev if you have an external drive that doesn't hold any system files.

[–] [email protected] 13 points 3 days ago (1 children)

No, it's XML. It's an ancestor of HTML and, unlike HTML, it can be losslessly converted.

[–] [email protected] 8 points 3 days ago (1 children)

Not quite. XML came several years after HTML! Both are descendants of SGML.

[–] [email protected] 1 points 2 days ago
[–] [email protected] 24 points 3 days ago
[–] [email protected] 16 points 3 days ago* (last edited 1 day ago) (1 children)

Ommigod, these kids :)

SVG comes XML (a more coherent/simple version of the SGML that is behind HTML), and specifically from a time where people took XML and made it hyper-complicated with a flurry of extensions and specifications (look up "xml namespaces" "xslt" "xml schema").

The most apparent difference between SGML and XML is than in the former you write tags like <br> without a corresponding </br>, and in the latter you have to close them like <br/> (which is shorthand for <br></br>).

So... today you learned that what you learned earlier today was close to truth, but not true :)

PS: A lot of document formats are undercover/zipped XML (eg. the libre office documents, IIRC microsoft's .xlsx and .docx). This is not dissimilar to how json/yaml are widely used today.

[–] [email protected] 1 points 2 days ago (1 children)

So, my Lemmy app - and I think a lot of Lemmy, renders markdown, so whenever you write "<...>" It disappears for me!

[–] [email protected] 2 points 1 day ago (1 children)

I tried adding backslashes to escape, it still looks fine on lemmy.ml but your app may be bugged (and possibly vulnerable to xss? can you see the script block after the closed bracket?) alert('you should not see an alert')

[–] [email protected] 1 points 22 hours ago

It all looks good now :-)

[–] [email protected] 7 points 3 days ago (2 children)

for example, on a linux distro, we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it.

this has largely happened; if you're on a dpkg-based distro try running this command:

dpkg -S svg | grep svg$ | sort

...and you'll see that your distro includes thousands of SVG files :)

explanation of that pipeline:

  • dpkg -S svg - this searches for files installed by the package manager which contain "svg" in their path
  • grep svg$ - this filters the output to only show paths which end with svg; that is, the actual svg files. the argument to grep is a regular expression, where $ means "end of line". you can invert the match (to see the paths dpkg -S svg found which only contain "svg" in the middle of the path) by writing grep -v svg$ instead.
  • the sort command does what it says on the tin, and makes the output easier to read

you can run man dpkg, man grep, and man sort to read more about each of these commands.

[–] [email protected] 2 points 3 days ago* (last edited 3 days ago)

Is this the same as pacman -Ql?

Edit: the dpkg part is.

[–] [email protected] 1 points 3 days ago

for alpine linux users:

apk info -L $(apk info) | grep -v contains | grep 'svg'
[–] [email protected] 3 points 3 days ago (1 children)

I made an interactive map: drew in Inkscape, gave the interactive elements numbers for ids, then substituted the id='xxx' in vim with the php code and js function calls, picking up the number from the id tag and inserting it appropriately in php code and function arguments. 250 interactive elements taken care of in a single vim substitute. My bestest development power move yet :D

[–] [email protected] 1 points 3 days ago (1 children)

What was the map used for?

[–] [email protected] 2 points 3 days ago (1 children)

It's a map of fairground lots for a service that takes bookings, bills the customer and deals with providing relevant safety info to authorities. In use again this season :)

[–] [email protected] 1 points 3 days ago

Yo that’s super cool! My nerd brain went straight to a virtual table top map for D&D

[–] [email protected] 4 points 3 days ago

Postscript is also literally just a text based programming language for drawing stuff. You can create loops and recursions and all kinds of crazy transformations with a few lines of code.

[–] [email protected] 8 points 3 days ago

we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it

That's already happening.

You can also change the main color of many SVGs (icons or even desktop backgrounds) with one simple edit, one command, one click.

In web sites, you can assign CSS classes to SVG graphics and thus e.g. change their color according to a theme.

That's my extent of fiddling with it.

IIRC they also use fonts the same way CSS/HTML does.

BTW, there are situations where an SVG is significantly larger than a corresponding raster image. It depends on the content.

[–] [email protected] 27 points 3 days ago

They can include runnable JavaScript too, which can cause vulnerabilities in certain contexts. One example from work some years back: We had a web app where users could upload files, and certain users could view files uploaded by others. They had the option to download the file or, if it was a file type that the browser could display (like an image or a PDF), the site would display it directly on the page.

To prevent any XSS (scripts from user-provided files), we served all files with the CSP sandbox header, which prevents any scripts from running. However, at the time, that header broke some features of the video player on certain browsers (I think in Safari, at least), so we had to serve some file types without the header. Mistakenly, we also included image files in the exclusion, as everyone through image files couldn't contain scripts. But the MIME type for SVG files is image/svg+xml... It was very embarrassing to have such a simple XSS vuln flagged in a security audit.

[–] [email protected] 10 points 3 days ago* (last edited 3 days ago) (1 children)

main difference between raster graphics and vector graphics was the quality

It's not. The primitives, the most basic constitutive building blocks, are different, for raster it's the pixel (a mix of colors, e.g. red/green/blue) whereas for vector it's the ... vector (a relative position elements, e.g. line, circle, rectangle or text start with).

This is a fundamental distinction on how you interact with the content. For raster you basically paint over pixels, changing the values of pixels, whereas for vector you change values of elements and add/remove elements. Both can be lossless though (vector always is) as for raster can have no compression or lossless compression. That being said raster does have a grid size (i.e. how many pixels are stored, e.g. 800x600) whereas vector does not, letting you zoom infinitely and see no aliasing on straight lines.

Anyway yes it's fascinating. In fact you can even modify SVG straight from the browser, no image editor or text editor needed, thanks to your browser inspector (easy to change the color of a rectangle for example) or even the console itself then via JavaScript and contentDocument you can change a lot more programmatically (e.g. change the color of all rectangles).

It's a lot of fun to tinker with!

[–] [email protected] 5 points 3 days ago (1 children)

I'm not sure that lossy compression on vectors is strictly impossible.

You can do things like store less colour information and simplify splines so that curves are less complex.

[–] [email protected] 2 points 3 days ago* (last edited 3 days ago)

True, in fact I've done so myself (simplifying a curve resulting of hand sketching). Still I'd argue that's not the expected behavior of storing the vector file but rather explicitly modifying it.

[–] [email protected] 1 points 3 days ago (1 children)

Damn, I actually did not know that. I thought it was just an image file.

[–] [email protected] 3 points 3 days ago (1 children)
[–] [email protected] 2 points 3 days ago* (last edited 3 days ago) (1 children)
[–] [email protected] 2 points 3 days ago

Yeah, it depends on if you view source

load more comments
view more: next ›