[Tuxpaint-devel] Gimp script-fu to help create stamps
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
|
From: Pere P. i C. <pe...@fo...> - 2007-07-28 11:41:42
|
Hi all! When porting the Childsplay images to Tuxpaint it comes clear to me that the stamp creation should be as automatized as possible. I've begin to learn the gimp script-fu language and come with this script: http://fornol.no-ip.org/linux/tuxpaint/scripts/mktpstamp.scm It is developed under gimp 2.3.18 ,and don't work under stable 2.2.XX series. It is work in progress and have some questions that I ask as I comment the script. You can follow my comments about editing the image by looking at http://fornol.no-ip.org/linux/tuxpaint/scripts/Dumper_scaled.xcf It is a 4.2MB dowload, the original image is about 20MB and I've not putted on the web. I use the script in this way: Put the script in .gimp-2.3/scripts directory and chmod 755 it If gimp is already started, go to Extensions->Script-fu and reload the functions. Prepare the image as in the advanced stamps howto. Hide the topmost layer. Now add a wite layer on top of WIP layer. Select transparency about 30%-60% for this layer depending on subject. Outline in this layer the subject you want with the 1 pixel brush (hold the shift key and go clicking around the edge, the more curve, the more join the clicks.) Add a new transparent layer on top of Outline.(Working1) Go to Outline, select by neighbour the interior of outline, go to the WIP layer, CTRL+C to copy, Go to Working1, CTRL+V to paste, CTRL+H to attach. Duplicate Working1<->Working2 as this we have a backup. Hide all layers except Contrast ones and Working2, edit the image in Working2. Add a layer mask on Working2 using the alpha value (not transfering it, just use it). Let the mask as is, antialias should be done by the script. Now check the edges of subject, there seems to be some weird effects caused by light. Duplicate Working2<->Working3, hide Working2. (a new backup) In Working3 select by color transparent, grow the selection by 1,2 or 3 pixels at most, CTRL+X to delete those pixels, now you should get ride of most of light effects on egdes of subject. Finish editing the edge if there rest some light effect. Now we have a subject lying on a transparent layer and a sharped mask. Set the image in this layer to edit (not the mask) and run the script. Script-fu->alchemy->mktpstamp You will be prompted by several things: Runs: The script will expand the edges of the subject 5 pixels around per run, so if you want the edge be expanded 30 pixels you should put 6 here. BTW this should be calculated from the original and final sizes, so a question is How many pixels should be expanded in order to avoid problems with edges when tuxpaint scales down? Use the current foreground color: The transparent space left by the expansion of the edge will be filled with the average of color find at center of the image. If the subject has a hole there, this will not be a right average color for the subject. Selecting a right foreground color before running the script and checking this will do better results. Scale and max final size: If you want to scale check it, set the maximun size you want for the final image. If scale is not set the final size will not be used. BTW What size is a good default? Base filename without extension: .png will be appended Close the auxiliar image when done: Uncheck to see what is resulting and for debugging purposes.(The undo button will work) Create .txt file: If you want to create the companion .txt files coming with stamps. Name will be base filename with appended .txt Text to put: The descriptive text of the stamp Create .dat file: same as for .txt file Some values for .dat file. Here I have some questions: tintable and colorable are conflicting one with other? Scale field is right as say 40%. Is it allways right as 400% ? Click on OK when you are done, the script will begin its work. First it will expand the edge of the image using the pixels on the edge of the subject. To do this, each run it copies and displaces around the layer on all pixels in a 5 pixels circle from exterior to interior (this implies the creation and destruction of 49 layers per run). Now the image will be displayed Second will fill the rest of the image using a calculated color or the foreground one. Scale if required. I've seen some strange effects using lanczos, now I use cubic interpolation in gimp->edit->preferences->Option Tools->Scale interpolation. May be it should be hardcoded in the script. Blur the mask --> antialias. We should check if it is enouth or needs more love and may be make it optional for people wanting to hand edit the mask. BTW scaling blurs the mask as well. Save as png and keep the values of transparent pixels close the image if required create .txt and .dat if required You can see the results of applying the script over the above xcf at http://fornol.no-ip.org/linux/tuxpaint/scripts/dumper.png or .txt or .dat What do you think about? Can it be usefull? Other comments? Thanks Pere |