moviepy icon indicating copy to clipboard operation
moviepy copied to clipboard

TextClip Stroke is applied inside the characters

Open robin-garnham opened this issue 4 years ago • 3 comments

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: Screen Shot 2020-09-17 at 9 51 11 pm

Without stroke: Screen Shot 2020-09-17 at 9 51 16 pm

With stroke of 10 (top line only): Screen Shot 2020-09-17 at 9 52 58 pm

robin-garnham avatar Sep 17 '20 12:09 robin-garnham

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.

SDwarfs avatar Jan 27 '21 03:01 SDwarfs

@robin-garnham Does the above comment solve your issue?

keikoro avatar Jan 05 '22 21:01 keikoro

Hey, so is there a way to stroke on the outside of TextClip? default strokes inside

litlol avatar Feb 05 '22 15:02 litlol

Hi, has anyone found a solution to this so that the outline can be applied to the outside of the text?

rbailis99 avatar Sep 29 '22 21:09 rbailis99

Closing this issue as it hasn't seen any response from OP (to a solution suggested up-thread) in a couple of years.

keikoro avatar Oct 11 '22 00:10 keikoro

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 avatar Nov 01 '22 23:11 rbailis99

@rbailis99 I don't understand what's not to understand about my previous comment.

keikoro avatar Nov 02 '22 09:11 keikoro

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.

rbailis99 avatar Nov 02 '22 13:11 rbailis99

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).

keikoro avatar Nov 16 '22 22:11 keikoro

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.

keikoro avatar Nov 16 '22 22:11 keikoro

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.

KateHutch avatar Apr 15 '23 04:04 KateHutch

Thanks for sharing, @KateHutch!

keikoro avatar Apr 19 '23 20:04 keikoro

Code exampleeee pleaseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

MASSKAgithub avatar Feb 05 '24 12:02 MASSKAgithub