GIMP Chat http://gimpchat.com/ |
|
create_valentine_day_card.py (Requested by Issabella) updated http://gimpchat.com/viewtopic.php?f=9&t=19094 |
Page 1 of 1 |
Author: | Pocholo [ Tue Jan 26, 2021 2:23 pm ] | |||
Post subject: | create_valentine_day_card.py (Requested by Issabella) updated | |||
Hi again everyone! Valentine's day is coming up here in America and I just want to share this Valentine's plugin with Issabella and everyone here in GC. The Valentine's file was share by Issabella and inspire by Conbagui work: https://www.deviantart.com/conbagui/art ... -795783382 Please leave comments and suggestions! ![]() ![]() The new version v2 have option to change the "Background pattern, the Lace color, the Heart color and the Text color.
|
Author: | Issabella [ Tue Jan 26, 2021 2:55 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
Pocholo, you are a crack for efficiency. ![]() ![]() I miss the brush named "solid rectangle" Could you post it for us, please? Thank you so much. |
Author: | Pocholo [ Tue Jan 26, 2021 4:29 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
I included in the main folder, please download the zip again. Thank you for letting me know, Issabella. |
Author: | Issabella [ Wed Jan 27, 2021 1:13 am ] | |||
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) | |||
Thank you so much Pocholo. It works great and quickly. ![]() ![]()
|
Author: | MareroQ [ Wed Jan 27, 2021 3:04 am ] | ||
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) | ||
Hi Pocholo. A very nice result. However, You should improve the color selectability (You specified a color instead of a variable). The plugin will also not work in the non-English version of Gimp (by using "Selection" - which is automatically translated). And here are two solutions - name it differently or introduce internationalization (better).
|
Author: | MareroQ [ Wed Jan 27, 2021 2:13 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
You deleted the question ![]() ![]() It's best to look at the code that works in Gimp - e.g. foggify.py. But here you fell into an additional trap of reusing plug_in_sel2path. Once you know how to internalize, it's easy (but I haven't changed a few of my older plugins myself yet ![]() Yet a minor question: Are you intentionally using different layer modes (old and new)? |
Author: | Pocholo [ Wed Jan 27, 2021 2:29 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
MareroQ wrote: You deleted the question ![]() ![]() It's best to look at the code that works in Gimp - e.g. foggify.py. But here you fell into an additional trap of reusing plug_in_sel2path (instead of writing a lot about it, see the #MrQ comments in your code - it will only be available temporarily). Once you know how to internalize, it's easy (but I haven't changed a few of my older plugins myself yet ![]() Yet a minor question: Are you intentionally using different layer modes (old and new)? Sorry MQ, I was going to ask the question because I remember you show me in one of my plugins. If I can remember it was "pm_icon_pressed_effect". But I appreciate your fast response. |
Author: | Pocholo [ Wed Jan 27, 2021 3:09 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
Pocholo wrote: MareroQ wrote: You deleted the question ![]() ![]() It's best to look at the code that works in Gimp - e.g. foggify.py. But here you fell into an additional trap of reusing plug_in_sel2path (instead of writing a lot about it, see the #MrQ comments in your code - it will only be available temporarily). Once you know how to internalize, it's easy (but I haven't changed a few of my older plugins myself yet ![]() Yet a minor question: Are you intentionally using different layer modes (old and new)? Sorry MQ, I was going to ask the question because I remember you show me in one of my plugins. If I can remember it was "pm_icon_pressed_effect". But I appreciate your fast response. I internationalized the plugin, but in the other language like Spanish, the plugin gives an error. What am I doing wrong here? ![]() [code]1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 4 # Inspire by Conbagui tutorial found here: https://www.deviantart.com/conbagui/art ... -795783382 5 # author: Pocholo 6 # date: 6/6/20 7 8 # Comments directed to http://gimpchat.com 9 10 # Installation: 11 # This script should be placed in the user plugin folder 12 13 # Copyright (C) 14 15 # This program is free software: you can redistribute it and/or modify 16 # it under the terms of the GNU General Public License as published by 17 # the Free Software Foundation, either version 3 of the License, or 18 # (at your option) any later version. 19 20 # This program is distributed in the hope that it will be useful, 21 # but WITHOUT ANY WARRANTY; without even the implied warranty of 22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 # GNU General Public License for more details. 24 # 25 # You should have received a copy of the GNU General Public License 26 # along with this program. If not, see <https://www.gnu.org/licenses/>. 27 28 from gimpfu import * 29 import gettext 30 import os, sys,time 31 32 gettext.install("gimp20", gimp.locale_directory, unicode=True) 33 34 def create_valentine_day_card(pattern, ribboncolor, lacecolor, customtext, fontname, textsize): 35 36 #Initiates the temporary state 37 pdb.gimp_context_set_defaults() 38 pdb.gimp_context_set_default_colors() 39 40 #Variables 41 size = 2000 42 43 #Create background layer 44 img = pdb.gimp_image_new(size, size, RGB) 45 backLayer = pdb.gimp_layer_new(img, size, size, RGB, "Background", 100, LAYER_MODE_NORMAL) 46 pdb.gimp_layer_add_alpha(backLayer) 47 pdb.gimp_image_add_layer(img, backLayer, 0) 48 pdb.gimp_context_set_pattern(pattern) 49 pdb.gimp_drawable_edit_fill(backLayer, FILL_PATTERN) 50 pdb.gimp_display_new(img) 51 52 #Create the ribbon 53 ribbonLayer = pdb.gimp_layer_new(img, size, size, RGB_IMAGE, "Ribbon", 100, LAYER_MODE_NORMAL) 54 pdb.gimp_image_add_layer(img, ribbonLayer, 0) 55 pdb.gimp_layer_add_alpha(ribbonLayer) 56 pdb.gimp_drawable_fill(ribbonLayer, FILL_TRANSPARENT) 57 pdb.gimp_context_set_foreground(ribboncolor) 58 pdb.gimp_image_select_rectangle(img, 2, 0, 850, 2000, 300) 59 pdb.gimp_edit_bucket_fill(ribbonLayer, BUCKET_FILL_FG, LAYER_MODE_NORMAL, 100, 255, FALSE, 0, 0) 60 pdb.python_layerfx_outer_glow(img, ribbonLayer, 61 (0, 0, 0), #color 62 75, #opacity 63 0, #contou 64 0, #noise 65 3, #mode - multiply 66 0, #spread 67 6, #size 68 TRUE, #knockout 69 FALSE) #merge 70 71 72 #Create the stitches on the ribbon 73 stitches = pdb.gimp_layer_new(img, size, size, RGB, "Stitches", 100, LAYER_MODE_NORMAL) 74 pdb.gimp_image_add_layer(img, stitches, 0) 75 pdb.gimp_layer_add_alpha(stitches) 76 pdb.gimp_drawable_fill(stitches, FILL_TRANSPARENT) 77 pdb.gimp_selection_shrink(img, 35) 78 pdb.plug_in_sel2path(img, stitches) 79 pdb.gimp_selection_none(img) 80 pdb.gimp_context_set_foreground('White') 81 pdb.gimp_brushes_set_brush("Solid Rectangle") 82 pdb.gimp_context_set_brush_size(25) 83 pdb.gimp_context_set_brush_angle(0) 84 pdb.gimp_context_set_brush_spacing(1.5) 85 pdb.gimp_context_set_brush_default_hardness() 86 pdb.gimp_context_set_paint_method("gimp-paintbrush") 87 pdb.gimp_context_set_stroke_method(STROKE_PAINT_METHOD) 88 vectors1 = pdb.gimp_image_get_vectors_by_name(img, "Selection") 89 pdb.gimp_drawable_edit_stroke_item(stitches, vectors1) 90 pdb.gimp_layer_scale(stitches, 3000, 2000, TRUE) 91 pdb.gimp_layer_resize_to_image_size(stitches) 92 pdb.python_layerfx_outer_glow(img, stitches, 93 (0, 0, 0), #color 94 100, #opacity 95 0, #contou 96 0, #noise 97 3, #mode - multiply 98 0, #spread 99 3, #size 100 TRUE, #knockout 101 FALSE) #merge 102 103 #Create a new from visible and rotate layer 104 pdb.gimp_item_set_visible(backLayer, FALSE) 105 ribbon2 = pdb.gimp_layer_new_from_visible(img, img, "Lace Text") 106 pdb.gimp_image_add_layer(img, ribbon2, 0) 107 ribbon2 = pdb.gimp_item_transform_rotate_simple(ribbon2, ROTATE_90, TRUE, 100, 100) 108 pdb.gimp_item_set_visible(backLayer, TRUE) 109 pdb.gimp_item_set_name(ribbon2, "Ribbon (vertical)") 110 111 #Create the heart 112 heartLayer = pdb.gimp_layer_new(img, size, size, RGB_IMAGE, "Heart", 100, LAYER_MODE_NORMAL) 113 pdb.gimp_layer_add_alpha(heartLayer) 114 pdb.gimp_image_add_layer(img, heartLayer, 0) 115 pdb.gimp_drawable_fill(heartLayer, FILL_TRANSPARENT) 116 pdb.gimp_brushes_set_brush("Best heart") 117 pdb.gimp_context_set_brush_size(1500) 118 pdb.gimp_context_set_brush_default_hardness() 119 pdb.gimp_context_set_brush_spacing(0.01) 120 pdb.gimp_context_set_brush_force(1) 121 pdb.gimp_context_set_foreground((244, 178, 184)) 122 pdb.gimp_paintbrush_default(heartLayer, 2, [1000, 1000]) 123 pdb.gimp_paintbrush_default(heartLayer, 2, [1000, 1000]) 124 125 #Create the lacing on the heart 126 laceLayer = pdb.gimp_layer_new(img, size, size, RGB, "Lace", 100, LAYER_MODE_NORMAL) 127 pdb.gimp_image_add_layer(img, laceLayer, 1) 128 pdb.gimp_layer_add_alpha(laceLayer) 129 pdb.gimp_drawable_fill(laceLayer, FILL_TRANSPARENT) 130 pdb.gimp_image_select_item(img, 2, heartLayer) 131 pdb.plug_in_sel2path(img, laceLayer) 132 pdb.gimp_selection_none(img) 133 pdb.gimp_context_set_foreground(lacecolor) 134 pdb.gimp_brushes_set_brush("Lace heart brush") 135 pdb.gimp_context_set_brush_size(250) 136 pdb.gimp_context_set_brush_angle(0) 137 pdb.gimp_context_set_brush_spacing(0.85) 138 pdb.gimp_context_set_brush_default_hardness() 139 pdb.gimp_context_set_paint_method("gimp-paintbrush") 140 pdb.gimp_context_set_stroke_method(STROKE_PAINT_METHOD) 141 vectors2 = pdb.gimp_image_get_vectors_by_name(img, "Selection #1") 142 pdb.gimp_drawable_edit_stroke_item(laceLayer, vectors2) 143 pdb.python_layerfx_outer_glow(img, laceLayer, 144 (0, 0, 0), #color 145 40, #opacity 146 0, #contou 147 0, #noise 148 3, #mode - multiply 149 0, #spread 150 5, #size 151 TRUE, #knockout 152 FALSE) #merge 153 154 155 #Create the lacing stitches 156 stiches2 = pdb.gimp_layer_new(img, size, size, RGB, "Lacing stitches", 100, LAYER_MODE_NORMAL) 157 pdb.gimp_image_add_layer(img, stiches2, 0) 158 pdb.gimp_layer_add_alpha(stiches2) 159 pdb.gimp_drawable_fill(stiches2, FILL_TRANSPARENT) 160 pdb.gimp_image_select_item(img, 2, heartLayer) 161 pdb.gimp_selection_shrink(img, 35) 162 pdb.plug_in_sel2path(img, stiches2) 163 pdb.gimp_selection_none(img) 164 pdb.gimp_context_set_foreground('White') 165 pdb.gimp_context_set_line_cap_style(1) 166 pdb.gimp_context_set_line_dash_offset(0) 167 pdb.gimp_context_set_line_dash_pattern(3, [1.5, 3]) 168 pdb.gimp_context_set_line_join_style(JOIN_ROUND) 169 pdb.gimp_context_set_line_miter_limit(10) 170 pdb.gimp_context_set_line_width(10) 171 pdb.gimp_context_set_line_width_unit(PIXELS) 172 pdb.gimp_context_set_stroke_method (STROKE_LINE) 173 vectors3 = pdb.gimp_image_get_vectors_by_name(img, "Selection #2") 174 pdb.gimp_drawable_edit_stroke_item(stiches2, vectors3) 175 pdb.python_layerfx_outer_glow(img, stiches2, 176 (0, 0, 0), #color 177 75, #opacity 178 0, #contou 179 0, #noise 180 3, #mode - multiply 181 3, #spread 182 3, #size 183 TRUE, #knockout 184 FALSE) #merge 185 186 #Create the text 187 textW = size/3.3 188 textH = size/3.3 189 pdb.gimp_context_set_foreground((255, 255, 255)) 190 textLayer = pdb.gimp_text_fontname(img, None, 0, 0, customtext, 10, 1, textsize, PIXELS, fontname) 191 pdb.gimp_text_layer_set_justification(textLayer, TEXT_JUSTIFY_CENTER) 192 pdb.gimp_text_layer_set_letter_spacing(textLayer, 0) 193 pdb.gimp_text_layer_set_line_spacing(textLayer, -30) 194 195 #Resize text 196 pdb.gimp_layer_scale (textLayer, textW, textH, TRUE) 197 198 #Making the text centered 199 textLayer = pdb.gimp_image_get_active_layer(img) 200 pdb.gimp_image_set_active_layer(img, textLayer) 201 wh = pdb.gimp_drawable_width(textLayer) 202 hh = pdb.gimp_drawable_height(textLayer) 203 w = pdb.gimp_image_width(img) 204 h = pdb.gimp_image_height(img) 205 pdb.gimp_image_set_active_layer(img,textLayer) 206 centerx=w/2 207 centery=h/2 208 adw=wh/2 209 adh=hh/2 210 sw=centerx - adw 211 sh=centery - adh 212 pdb.gimp_layer_set_offsets(textLayer, sw, sh) 213 pdb.gimp_layer_resize_to_image_size(textLayer) 214 pdb.gimp_layer_set_offsets(textLayer, 15, 40) 215 pdb.gimp_layer_resize_to_image_size(textLayer) 216 pdb.python_layerfx_outer_glow(img, textLayer, 217 (0, 0, 0), #color 218 30, #opacity 219 0, #contou 220 0, #noise 221 3, #mode - multiply 222 0, #spread 223 3, #size 224 TRUE, #knockout 225 FALSE) #merge 226 227 #Design 228 designLayer = pdb.gimp_layer_new(img, size, size, RGB_IMAGE, "Designs", 100, LAYER_MODE_NORMAL) 229 pdb.gimp_layer_add_alpha(designLayer) 230 pdb.gimp_image_add_layer(img, designLayer, 0) 231 pdb.gimp_drawable_fill(designLayer, FILL_TRANSPARENT) 232 pdb.gimp_brushes_set_brush("Flowers & Swirls 1") 233 pdb.gimp_context_set_brush_size(200) 234 pdb.gimp_context_set_brush_default_hardness() 235 pdb.gimp_context_set_brush_spacing(0.01) 236 pdb.gimp_context_set_brush_force(0.50) 237 pdb.gimp_context_set_foreground('White') 238 pdb.gimp_paintbrush_default(designLayer, 2, [636, 772]) 239 non_empty = pdb.gimp_edit_copy(designLayer) 240 designcopy = pdb.gimp_layer_new(img, size, size, RGB_IMAGE, "Designs copy", 100, LAYER_MODE_NORMAL) 241 pdb.gimp_layer_add_alpha(designcopy) 242 pdb.gimp_image_add_layer(img, designcopy, 0) 243 pdb.gimp_drawable_fill(designcopy, FILL_TRANSPARENT) 244 designcopy = pdb.gimp_edit_paste(designcopy, FALSE) 245 pdb.gimp_floating_sel_anchor(designcopy) 246 designcopy = pdb.gimp_image_get_layer_by_name(img, "Designs copy") 247 designcopy = pdb.gimp_flip(designcopy, ORIENTATION_HORIZONTAL) 248 designcopy = pdb.gimp_image_merge_down(img, designcopy, CLIP_TO_IMAGE) 249 designLayer = pdb.gimp_image_get_layer_by_name(img, "Designs") 250 pdb.python_layerfx_outer_glow(img, designLayer, 251 (0, 0, 0), #color 252 15, #opacity 253 0, #contou 254 0, #noise 255 3, #mode - multiply 256 0, #spread 257 3, #size 258 TRUE, #knockout 259 FALSE) #merge 260 261 #Set gimp to default 262 pdb.gimp_context_set_defaults() 263 pdb.gimp_context_set_default_colors() 264 265 register( 266 "create_valentine_day_card", 267 "Creates a Valentine day card", 268 "Creates a Valentine day card", 269 "Pocholo", 270 "Pocholo", 271 "2021", 272 "Create a Valentine day card", 273 "", 274[ 275 (PF_PATTERN, "pattern", "Background pattern", "Hearts pattern.jpg"), 276 (PF_COLOR, "ribboncolor", "Ribbon color", (244, 178, 184)), 277 (PF_COLOR, "lacecolor", "Lace color", (255, 255, 255)), 278 (PF_TEXT, "customtext", "Text string", "Happy\nValentine's\nDay"), 279 (PF_FONT, "fontname", "Font name", "Fiolex Girls"), 280 (PF_SPINNER, "textsize", "Text size", 185, (185, 185, 1)), 281], 282[], 283 create_valentine_day_card, menu="<Image>/Pocholo-scripts/Create a Valentine day card", 284 domain=("gimp20", gimp.locale_directory)) 285 main()[code] |
Author: | MareroQ [ Wed Jan 27, 2021 4:20 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
The magic of a few signs: ![]() _ ("Selection") |
Author: | mackenzieh [ Wed Jan 27, 2021 5:42 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
The plugin I have works well. ![]() |
Author: | Pocholo [ Thu Jan 28, 2021 12:31 am ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
Thank you Mackenzie. I'm trying to learn how to make the plugin work in internationally, other languages beside English. |
Author: | level_0 [ Thu Jan 28, 2021 2:42 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
![]() The chosen colors do not appear in the result.??? ![]() |
Author: | Pocholo [ Thu Jan 28, 2021 6:09 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
level_0 wrote: Sorry Level_0 ![]() ![]() |
Author: | mahvin [ Thu Jan 28, 2021 8:31 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
Is version 2 included with the files I posted to gimpscripts? |
Author: | mackenzieh [ Thu Jan 28, 2021 9:34 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
I like the new version but is there a way for the font size to have the option of making the font size larger or smaller? The size 185, is nice but from what I saw after I finished the card, the font size could increase some what. ![]() |
Author: | Pocholo [ Thu Jan 28, 2021 9:58 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) |
mahvin wrote: Is version 2 included with the files I posted to gimpscripts? Hi Mahvin. I just uploaded the new version "create_valentine_day_card.py version 2" @ www.gimpscripts.net. Can you post it, please? |
Author: | level_0 [ Fri Jan 29, 2021 1:15 pm ] |
Post subject: | Re: create_valentine_day_card.py (Requested by Issabella) updated |
![]() Thank you Pocholo for this 2nd version. It's great that the layers aren't merged.It allows you to quickly make a card to wish a birthday or healing wishes, because for my part I have no one to wish a valentine 's day. ![]() |
Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |