Skip to content

Commit b383b55

Browse files
Merge pull request #58 from StartAutomating/edits-Tue,03Jan202303-13-37GMT
Posting with GitPub [skip ci]
2 parents 12af116 + a6b27ed commit b383b55

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

docs/2022-12-29.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
permalink: /2022/12/29/
3+
---
4+
{% for post in site.posts %}
5+
{% assign currentdate = post.date | date: "%Y %m %d" %}
6+
{% assign friendlydate = post.date | date: "[%B](..) [%d](.) [%Y](../..)" %}
7+
{% if currentdate != "2022 12 29" %}
8+
{% continue %}
9+
{% endif %}
10+
{% if currentdate != date %}
11+
## {{friendlydate}}
12+
{% assign date = currentdate %}
13+
{% endif %}
14+
* [ {{ post.title }} ]( {{ post.url }} )
15+
{% endfor %}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
3+
title: Rasterizing SVGs with obs powershell
4+
author: StartAutomating
5+
sourceURL: https://github.com/StartAutomating/obs-powershell/issues/42
6+
---
7+
SVG is an amazing graphics format and a great web standard.
8+
9+
Unfortunately, it's also a standard that's not fully implemented by many imaging tools.
10+
11+
If, for instance, you want to rasterize an SVG with ImageMagik, go ahead and kiss your symbols goodbye and forget even using CSS classes. Many imaging apps can't handle large chunks of the SVG standard, which leads to omitted text and elements.
12+
13+
And don't even get me started on _animated_ SVGs.
14+
15+
Luckily, OBS has a browser source, and lets us easily capture an SVG as an image or a video _exactly as it would render in Chrome_.
16+
17+
Let's cover images first.
18+
19+
Because SVGs are scalable, and raster images are not, step one is to get our dimensions right.
20+
21+
SVGs have a Viewbox, which contains the width and height they'll want to render at.
22+
23+
Create a browser source of that width / height, then pipe it to Save-OBSScreen.
24+
25+
~~~PowerShell
26+
Add-OBSBrowserSource -Uri https://4bitcss.com/Batman.svg -Width 640 -Height 240 |
27+
Save-OBSSourceScreenshot -ImageFormat png -ImageFilePath (Join-Path $pwd "Batman.png")
28+
~~~
29+
30+
![Because I'm Batman](https://4bitcss.com/Batman.png)
31+
32+
Because of the Object Pipeline in PowerShell, we don't even need to pass along the -ImageHeight and -ImageWidth to Save-OBSSourceScreenshot (the browser source has an .ImageHeight and .ImageWidth property).
33+
34+
It gets even better.
35+
36+
The file that Save-OBSSourceScreenshot returns packs a little bit of extra info:
37+
38+
* What source generated it
39+
* What scene it was in
40+
41+
Which means we can actually just take a snapshot and remove it:
42+
43+
~~~PowerShell
44+
Add-OBSBrowserSource -Uri https://4bitcss.com/Batman.svg -Width 640 -Height 240 |
45+
Save-OBSSourceScreenshot -ImageFormat png -ImageFilePath (Join-Path $pwd "Batman.png") |
46+
Remove-OBSSceneItem
47+
~~~
48+
49+
Hope this Helps!

0 commit comments

Comments
 (0)