|
Script Coder |
|
Joined: Oct 25, 2010 Posts: 4756
|
>>> image = pdb.gimp_xcf_load(dummy_param, filename, raw_filename) >>> layer = pdb.gimp_text_layer_new(image, text, fontname, size, unit) >>> pdb.gimp_image_insert_layer(image, layer, parent, position)>>> pdb.gimp_text_layer_set_text(layer, text) Not really useful since you can set the text in gimp_text_layer_new >>> layer = pdb.gimp_layer_new_from_visible(image, dest_image, name) >>> pdb.file_png_save_defaults(image, drawable, filename, raw_filename)
Inputting my own information, I get... image = pdb.gimp_xcf_load(0, "C:\\E\\D\\C\\B\\A.xcf", "A.xcf") layer = pdb.gimp_text_layer_new(“A”, “TextLayer”, “Arial”, 64, 1)Actually: layer = pdb.gimp_text_layer_new(image, “TextLayer”, “Arial”, 64, UNIT_PIXEL)You have to understand what a variable is. There is a fairly good explanation on Wikipedia. The image parameter is the image variable you created when you did image = pdb.gimp_xcf_load(0, "C:\\E\\D\\C\\B\\A.xcf", "A.xcf"). The last parameter is a number, but using one of the "constant variables" that are initialized with numeric values is much more readable and avoids errors. For the complete list: >>> [u for u in dir() if "UNIT_" in u] ['UNIT_INCH', 'UNIT_MM', 'UNIT_PICA', 'UNIT_PIXEL', 'UNIT_POINT']
pdb.gimp_image_insert_layer(“A”, “TextLayer”, “Background”, (640, 640))pdb.gimp_image_insert_layer(image, layer, None,0), because image and layer are the two variables you set above. None tells that there is no parent (there is a parent if you insert your layer in a layer group). The position is not a position in (X,Y), but the position in the layer stack. 0 is the top position. pdb.gimp_text_layer_set_text("TextLayer", "Hello_World")As said above, not necessary since you have already set the text when you created the layer. But if you really want this, the first parameter is the variable that contains the current text layer: pdb.gimp_text_layer_set_text(layer, "Hello_World")layer = pdb.gimp_layer_new_from_visible("A", "A", "B")merged_layer = pdb.gimp_layer_new_from_visible(image,image, "New from visible")image is used twice, once to designate the image from which the new layer is constructed, and once to designate the target image. There are cases where you would use this to create the visible layer in another image and you would use two different image variables. Use a new variable merged_layer to hold the new layer. pdb.file_png_save_defaults("A", "B", "C:\\J\\K\\F\\O”, “O”)pdb.file_png_save_defaults(image,merged_layer, "C:\\J\\K\\F\\O”, “O”)Note that you don't add the layer to the image ( pdb.gimp_image_insert_layer(...)) but AFAIK you don't need this to save the image. and when inputted into the console this appears...
>>> image = pdb.gimp_xcf_load(0, "C:\\E\\D\\C\\B\\A.xcf", "A.xcf") Traceback (most recent call last): File "<input>", line 1, in <module> RuntimeError: Could not open 'C:\\E\\D\\C\\B\\A.xcf' for reading: No such file or directory >>> layer = pdb.gimp_text_layer_new(“A”, “TextLayer”, “Arial”, 64, 1) File "<input>", line 1 layer = pdb.gimp_text_layer_new(“A”, “TextLayer”, “Arial”, 64, 1) ^ SyntaxError: invalid syntax >>> pdb.gimp_image_insert_layer(“A”, “TextLayer”, “Background”, (640, 640)) File "<input>", line 1 pdb.gimp_image_insert_layer(“A”, “TextLayer”, “Background”, (640, 640)) ^ SyntaxError: invalid syntax >>> pdb.gimp_text_layer_set_text("TextLayer", "Hello_World") Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: wrong parameter type >>> layer = pdb.gimp_layer_new_from_visible("A", "A", "B") Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: wrong parameter type >>> pdb.file_png_save_defaults("A", "B", "C:\\J\\K\\F\\O”, “O”)
I cannot see any clear mistakes within my script. I do think that there may be an error in the way that I inputted the "image" criteria; please let me know the proper way to do it if it is wrong. Regardless of all this, thanks again for your detailed response, I really do appreciate it.Mostly you are confusing the "names" of the images and layers (as displayed in the UI) with the names of variables that hold these "object" in the program.
_________________
|
|