"Ghost" python plugin?

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:gimp: :golden_wilber: :gimplearn: :NewGL: :GL2: :favicon4: :award_trophy: :polygon_award_trophy: :Ella_trophy_award: :gimp_learn_olympic_medal: :thumbsup: :2_Thumbs: :download: :learned_something: :gimp_clap: :hammer_head: :happy_purple: :yay_yay_purple: :giggle_purple: :evil_laugh_purple: :lmao_purple: :rofl: :aw_shucks_purple: :off_to_bed_purple: :blowing_hearts: :cool: :ninja: :scared_smilie: :red_heart: :white_heart: :thumbs_up_love_recieved: :stars_1: :stars_2: :stars_3: :stars_4: :stars_5: :public_domain: :fb_like: :fb_love: :fb_haha: :fb_wow: :fb_sad: :fb_angry: :bull_riding: :paint :computer_smiley: :confetti: :terrific: :congrats: :crysmiley: :hi5: :goodjob: :popcorn: :hearts_smiley: :pompom: :drinking_smilies: :wine_smiley: :smiley_toss: :gaah: :i_care: :kungfu: :photosmiley: :snap: :trampoline: :tantrum: :yes: :thank_you: :tick_tock: :thats_awesome: :what she said: :what he said: :2_10_rectangle_select_tool: :2_10_ellipse_select_tool: :2_10_free_select_tool: :2_10_fuzzy_select_tool: :2_10_select_by_color_tool: :2_10_scissors_select_tool: :2_10_foreground_select_tool: :2_10_paths_tool: :2_10_color_picker_tool: :2_10_zoom_tool: :2_10_measure_tool: :2_10_move_tool: :2_10_alignment_tool: :2_10_crop_tool: :2_10_unified_transform_tool: :2_10_rotate_tool: :2_10_scale_tool :2_10_shear_tool: :2_10_handle_transform_tool: :2_10_perspective_tool: :2_10_flip_tool: :2_10_cage_transform_tool: :2_10_warp_transform_tool: :2_10_text_tool: :2_10_bucket_fill_tool: :2_10_gradient_tool: :2_10_pencil_tool: :2_10_paintbrush_tool: :2_10_eraser_tool: :2_10_airbrush_tool: :2_10_ink_tool: :2_10_mypaint_brush_tool: :2_10_clone_tool: :2_10_healing_tool: :2_10_perspective_clone_tool: :2_10_blur_sharpen_tool: :2_10_smudge_tool: :2_10_dodge_burn_tool: :2_10_foreground_background: :rectangle_select: :ellipse_select: :free_select: :fuzzy_select: :select_by_color: :scissors_select: :foreground_select: :paths: :color_picker: :zoom: :measure: :move: :alignment: :crop: :rotate: :scale: :shear: :perspective: :flip: :cage_transform: :text: :bucket_fill: :blend: :pencil: :paintbrush: :eraser: :airbrush: :ink: :clone: :healing: :perspective_clone: :blur_sharpen: :smudge: :dodge_burn: :foreground_background: :D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek: :tree_01: :tree_02: :tree_03: :tree_04: :tree_05: :tree_06: :tree_07: :tree_08: :tree_09: :tree_10: :tree_11: :tree_12:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: "Ghost" python plugin?

Re: "Ghost" python plugin?

by tim » 22 Jun 2019, 12:44

glad you finally got it working.
Don't hesitate to ask more if you run into other problems :D
Cheers.

Re: "Ghost" python plugin?

by vndep » 22 Jun 2019, 10:45

BTW you are a godsend - your responses in another post (viewtopic.php?f=9&t=1210) solved another problem.

Re: "Ghost" python plugin?

by vndep » 22 Jun 2019, 09:45

<groan> I am used to coding in an IDE so little stupid errors like new_img vs. new_image are tripping me up!
now it works.

Re: "Ghost" python plugin?

by tim » 22 Jun 2019, 03:58

what's the error? it ran when i tested on mine.
you had it as new_img when it should be new_image

Re: "Ghost" python plugin?

by vndep » 22 Jun 2019, 02:45

That also throws an error.

Re: "Ghost" python plugin?

by tim » 21 Jun 2019, 22:09

as a rule in python fu GIMP plug-ins,
The run mode is not used if it's used it's a named parameter so just ignore that first parameter can call it with

Code: Select all

pdb.gimp_file_save(new_image, layer, outputpath, outputpath)

Re: "Ghost" python plugin?

by vndep » 21 Jun 2019, 21:34

Oops ... another question.

All the code below works except one line and I can't figure out why; the line is:

pdb.gimp_file_save(1, new_img, layer, outputpath, 'AAA_TEST.png')

The objective is to save my work as a png file.

Code: Select all


def python_sample_scriptC(image, layer) : #FUNCTION DEFINITION
	pdb.gimp_image_undo_group_start(image)
	pdb.gimp_context_push()
	#YOUR CODE BEGINS=======================

	imagepath = 'G:/Users/Star/Dropbox/Projects/Stock photos/blue-clouds-day-53594.jpg'
	outputpath = 'G:/Users/Star/Dropbox/Projects/Stock photos/AAA_TEST.png'
	text = 'SAMPLE TEXT'
	drawableFLAG = None
	xval = 10
	yval = 10
	borderval = 0 
	antialiasFLAG = FALSE
	sizeval = 100
	sizetypeval = 1
	fontnameval = 'Arial Heavy'

	pdb.gimp_message('LOAD IMAGE')
	imageobj = pdb.file_jpeg_load(imagepath, imagepath)
	pdb.gimp_display_new(imageobj)
	pdb.gimp_message('CREATE TEXT LAYER')
	textlayerval = pdb.gimp_text_fontname(imageobj, drawableFLAG, xval, yval, text, borderval, antialiasFLAG, sizeval, sizetypeval, fontnameval)
	pdb.gimp_message('SET TEXT COLOR')
	pdb.gimp_text_layer_set_color(textlayerval, '#ff0000')
	time.sleep(1)
	pdb.gimp_message('DUPLICATE')
	new_image = pdb.gimp_image_duplicate(imageobj)
	pdb.gimp_message('MERGE')
	layer = pdb.gimp_image_merge_visible_layers(new_image, CLIP_TO_IMAGE)
	pdb.gimp_message('SAVE')
#  THIS NEXT LINE PRODUCES AN ERROR
	pdb.gimp_file_save(1, new_img, layer, outputpath, 'AAA_TEST.png')


#	pdb.gimp_message('DELETE')
#	pdb.gimp_image_delete(new_image)



#	time.sleep(10)
#	pdb.gimp_message('TRY TO DELETE LAYER')
#	pdb.gimp_item_delete(textlayerval)
#	pdb.gimp_message('LAYER DELETED')

		


	#YOUR CODE ENDS ========================
	pdb.gimp_context_pop()
	pdb.gimp_image_undo_group_end(image)
	pdb.gimp_displays_flush()
    #return

Re: "Ghost" python plugin?

by vndep » 21 Jun 2019, 20:54

Thanks a lot! You have been a great help!

Re: "Ghost" python plugin?

by tim » 21 Jun 2019, 20:34

Thanks for asking btw (It gives me opportunity to be of your service :D)

Re: "Ghost" python plugin?

by tim » 21 Jun 2019, 20:19

here's the code

Code: Select all

#!/usr/bin/env python


import time
from gimpfu import *

def python_sample_scriptC(image, layer, imagepath) : #FUNCTION DEFINITION
	pdb.gimp_image_undo_group_start(image)
	pdb.gimp_context_push()
	#YOUR CODE BEGINS=======================

	#imagepath = 'G:/Users/Star/Dropbox/Projects/Stock photos/blue-clouds-day-53594.jpg'
	text = 'SAMPLE TEXT'
	drawableFLAG = None
	xval = 10
	yval = 10
	borderval = 0 
	antialiasFLAG = FALSE
	sizeval = 10
	sizetypeval = 1
	fontnameval = 'Arial'

	pdb.gimp_message('LOAD IMAGE')
	imageobj = pdb.file_jpeg_load(imagepath, imagepath)
	pdb.gimp_display_new(imageobj)
	pdb.gimp_message('CREATE LAYER')
	textlayerval = pdb.gimp_text_fontname(imageobj, drawableFLAG, xval, yval, text, borderval, antialiasFLAG, sizeval, sizetypeval, fontnameval)
#	time.sleep(10)
#	pdb.gimp_message('TRY TO DELETE LAYER')
#	pdb.gimp_item_delete(textlayerval)
#	pdb.gimp_message('LAYER DELETED')

		


	#YOUR CODE ENDS ========================
	pdb.gimp_context_pop()
	pdb.gimp_image_undo_group_end(image)
	pdb.gimp_displays_flush()
    #return

register(
	"python_fu_sample_scriptC",
	"Sample Python Fu Script",
	"Sample Python Fu Script...",
	"vndep",
	"vndep",
	"June 2019",
	"<Image>/Python-Fu/Sample_scriptC...",
	"*",      # Create a new image, don't work on an existing one
	[ 
	#INPUT BEGINS
	(PF_FILENAME, "imagepath", "Image File Path:", 0),
	#(PF_OPTION, "arrow_side", "Arrows Ends:", SIDE_END, SIDE_NAMES),
	#(PF_TOGGLE, "arrow_close", "Arrows Close:", 0),
	#(PF_SPINNER, "border_width", "Border Width (bevelled width):", 10, (0, 500, 1)),
	#(PF_SPINNER, "shadow_offset_x", "Shadow Offset X:", 6, (-4096,4096,1)),
	#(PF_SPINNER, "shadow_offset_y", "Shadow Offset Y:", 6, (-4096,4096,1)),
	#(PF_SPINNER, "shadow_blur_radius", "Shadow Blur Radius:", 15, (0,1024,1)),
	#(PF_SPINNER, "shadow_opacity", "Shadow Opacity:", 100, (0,100,1)),
	#INPUT ENDS
	],
	[],
	python_sample_scriptC)

main()
with a filename paramater for more parameter types see: viewtopic.php?p=11157#p11157

Top