If such a function existed, then the get_markup and set_markup functions would give a script complete control over text. Unfortunately, there is no set_markup function - even though it's been commented on and requested for 3-5 years now, so don't hold your breath. You can get the markup for your text this way: pdb.gimp_text_layer_get_markup(layer) Apparently gimp supports a markup language for text. In turns out that gimp text functionality is pretty poor, and there are lots of complaints surrounding issues like this online. The solution is, when you change text in the gimp editor you need to change the font in the tool dialog box, so it's set as a property of the layer, instead of just selecting the text and changing the font in the floating font box that shows up - that changes the font of the text you selected, but leaves the base font of the text layer unchanged. I've done a bit more research and found a solution that works for me in gimp, however, it sounds like you should probably be using something other than gimp, such as imagemagick, if you're doing much text editing from a script. Then, if I redesign the master file (which I will do a lot), I have to repeat the process. I would need to go through all the text fields, figure out what the font parameters are and hard code them in for each one. It doesn't seem to preserve italics etc., and I wouldn't expect it to preserve whether or not text is underlined.Ī third option would be to hard code in the font. It looks like the get_font and get_font_size commands retrieve the right font for one of the layers, but not for the others. Unfortunately, that doesn't seem to work consistently. Pdb.gimp_text_layer_set_font_size(text1_layer, font_size, font_unit) Pdb.gimp_text_layer_set_font(text1_layer, font) Pdb.gimp_text_layer_set_text(text1_layer, tex1_text) Text1_layer = filter(lambda x: x.name = 'text1', im.layers)įont = pdb.gimp_text_layer_get_font(text1_layer)įont_size, font_unit = pdb.gimp_text_layer_get_font_size(text1_layer) This is what I've tried: # Find the text layer Is there a way to change just the text and leave the font alone?Īlternately, a more clunky way would be to try and save everything important about the font before the change and try to reapply it. The problem is this also overwrites the font and other text parameters that I had picked out in the master file. I've successfully changed the text in my batch script with this function: pdb.gimp_text_layer_set_text(layer, text) I would like to leave the font, size, italicized or not, etc. I then want to use a python script to produce a bunch of new images with the text (on several different layers) changed. I have a master image which I edit in gimp to get the look and feel wanted.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |