Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th February 2020, 13:43   #1  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 54
Calculate width and height of sub.TextFile rendered text

Any idea how to calculate the width and height of sub.TextFile rendered text?

The goal is to crop the text to its used area only.
groucho86 is online now   Reply With Quote
Old 7th February 2020, 19:03   #2  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,080
Quote:
Originally Posted by groucho86 View Post
Any idea how to calculate the width and height of sub.TextFile rendered text?

The goal is to crop the text to its used area only.
Maybe it could be exported as a frame property.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 8th February 2020, 00:03   #3  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 54
Yes that could be useful!

I was playing around with "Wand" which is an ImageMagick binding for Python. It offers a "get_font_metrics" which returns something like:
Code:
FontMetrics(character_width=35.0, character_height=35.0, ascender=35.0, descender=-13.0, text_width=628.0, text_height=618.0,
            maximum_horizontal_advance=35.0, x1=5.5, y1=16.671875, x2=12.671875, y2=25.0, x=628.0, y=0.0)
Probably overkill for subtitling needs, but it is helpful.
groucho86 is online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:20.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.