moviepy
moviepy copied to clipboard
TextClip Stroke is applied inside the characters
Hey there,
Love the project, thanks all contributors.
The stroke property on TextClip seem to apply inside the characters, is there any way to change this to be on the outside? I have been trying to use the stroke as a mask (I select the stroke colour to the same as my background, so when it intersects with other elements they look nicer)
mp.TextClip(string_one, color = font_color, font = font_family, stroke_color = stroke_color, stroke_width = stroke_width, kerning = kerning, align = 'center', size = text_size ).set_duration(duration).set_position(lambda t: ('center', top_position))
Target:
Without stroke:
With stroke of 10 (top line only):
It seems the default color for the stroke is not set to the fill color. You need to set parameter 'stroke_color' to 'white' in your case (or whatever the color of your text is). This solved the issue for me.
@robin-garnham Does the above comment solve your issue?
Hey, so is there a way to stroke on the outside of TextClip? default strokes inside
Hi, has anyone found a solution to this so that the outline can be applied to the outside of the text?
Closing this issue as it hasn't seen any response from OP (to a solution suggested up-thread) in a couple of years.
Why was this marked as completed? We still need help getting the outline to be on the OUTSIDE of the text. It currently only shows on the inside.
On Oct 10, 2022, at 8:54 PM, k @.***> wrote:
Closed #1318 https://github.com/Zulko/moviepy/issues/1318 as completed.
— Reply to this email directly, view it on GitHub https://github.com/Zulko/moviepy/issues/1318#event-7557980469, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIHOIYKIB26Y2OTYOWNKBMTWCS3DRANCNFSM4RQLIB7Q. You are receiving this because you commented.
@rbailis99 I don't understand what's not to understand about my previous comment.
Thanks for responding. Who is OP? Does he/she know the answer to this issue?
I’ve still not been able to figure it out unfortunately.
Le 2 nov. 2022 à 05:16, k @.***> a écrit :
@rbailis99 I don't understand what's not to understand about my previous comment.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.
OP = original poster, in this case: the person who opened the issue.
New comments on old issues aren't necessarily helpful, especially when solutions were suggested but the initial issuer does not respond anymore. Often it's impossible to know for sure if later reports are really about the identical issue, also because parts of the code base change intermittently. – In this case, we don't have any info on which version of moviepy the original poster used (and if it's the same that other commenters used).
In a case like this, seeing as the issue was closed for the given reason, it would make more sense to create a new issue (following our issue template, in which we ask for e.g. platform, moviepy version,...) with own code samples + add a link to this older issue for reference.
Just putting this here for posterity (feel free to ignore). This is a fix to OP's original issue regarding MoviePy stroke being applied inside the characters.
- As we know, MoviePy uses ImageMagick to render text elements.
- According to the ImageMagick docs the strokewidth property expands the stroke both inside and outward.
- Therefore if you want to avoid the stroke line expanding inside the text (as per OP's original issue) you must draw the same text twice - once with a stroke, and then without the stroke.
- Overlaying the two TextClips will then create the result you want, and will retain only the outward stroke in the final product.
Note: you will also need to offset the position of the TextClip in MoviePy by the stroke width to achieve the correct effect.
Thanks for sharing, @KateHutch!
Code exampleeee pleaseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee