Re: [Gimp-user] How to write a "simple" macro [newbie]

2005-10-28 Thread Carol Spears
On Fri, Oct 28, 2005 at 07:34:11PM +0200, Mauro Condarelli wrote:
> > On Thu, Oct 27, 2005 at 11:46:52AM +0200, Mauro Condarelli wrote:
> I had a look to the script-fu docs and I sincerely have some 
> problems orienting in there.
> First the good news: I have little problems with scheme, after 
> several thousand lines of elisp hacking.
> ..then the problems: I have problems finding the "right way" 
> to do things. I browsed the available procedures (Xtns->Procedure Browser),
> but I did *not* find everything I need (see below).
> 
i am more familiar with python but the two have the same capabilities,
for the most part -- as far as gimp is concerned.

The script-fu console has a browse button, i highly recommend this for
looking over the gimp procedures with.

> What I would like to do is:
> 1) start some script and create a new layer for the translation
>   (ok, I should be able to do that)

this is not a one step process.  everytime i write a script that does
this, it is one of the points where there can easily be breakage.  maybe
i will put my adding a layer with a python script on my web journal
today.

> 2) wait for a mouse click somewhere (I didn't find a way to do that)
>   I will click on the white area of some comics text bubble.

i don't know how to do this with python short of involving pygtk.  i do
not think there is an equivelent to pygtk with script-fu.

there is no run-interactive ability with gimp scripting right now.

> 3) get the coordinates of the pixel clicked (don't know how to do that)

easy with c.  with scripts it is more that you tell where to get
information from, such as fuzzy select:
(gimp-fuzzy-select drawable x y threshold operation antialias feather
feather-radius sample-merged)
where x and y are the coordinates of initial seed fill point: (image
coordinates)

if text balloons are the only white parts on the images, select by color
might be something to think about.

you can get the area of a selection via scripting:
(gimp-selection-bounds image) returns x1, y1, x2, y2

> 4) start the magic-wand with the mouse click coordinates (gimp_fuzzy_select)

an interactive plug-in like this would need to be written in c or would
need the help of a wrapped set of widgets to script with, like pygtk --
i mentioned this already.

> 5) remove the inner "holes" in the selection due to the text to be erased.
>   I found a less-than-satisfactory way of doing that using 
>   (gimp_selection_grow img 7)(gimp_selection_shrink img 8).
>   I would like to do it algorythmically, but I have no idea which
>   procedures to use.

consider after removing the white parts, inverting the selection 
(gimp-selection-invert image) to get rid of the text.

> 6) move the selection to the translation layer 
>   (gimp_image_add_channel tlayer (gimp_selection_save img) 0) (???)

(gimp-selection-float drawable offx offy) i think if you use x1 and y1
from (gimp-selection-bounds image) it will work.  then make a new layer
of that.

> 7) clear the selection (in translation layer)
>   (gimp_context_set_background (gimp_image_pick_color img clickX clickY))
>   (gimp_drawable_fill (gimp_selection_save img) GIMP_BACKGROUND_FILL)

if you make sure the layer transparency is toggled
(gimp-layer-set-lock-alpha layer lock-alpha) you should be able to fill
the original pixel region without a lot of extra steps.  to do this,
float your selection first and make that into a new layer.  then invert
the selection and fill that.  then toggle the transparency and fill the
whole layer.

> 8) open a box to edit text and then render it to the new selection in tlayer
>   (gimp_textget_extens_fontname)/(gimp_text_fontname) ??
>   How do I get the dimensions of the "useful" area?
>   How do I get the text inteh first place? I would need some kind 
>   of text input box, but I found nothing :(

no input boxen are available, but i have explained this already.  what
is available is the means to calculate the text area and adjust the font
to that.

> > > 4) Edit a (possibly long) string and fit it into the cleared 
> > region (eventually scaling the font to make it fit).
> > >
> > via scripts, there are many many ways to control text.  you can 
> > see this
> > if you look at Xtns-->PDB Browser and search for text.
> I found nothing.
> Only low level procedures to actually render a string.
> No way to edit it.

it will take some medium level math.

and gimp only works on its own text layers.  i think that what you want
to do cannot be done with gimp.  when you make a text layer, the string
is available to be read by gimp, however.  maybe future projects can
make use of this.

> > the text is on its own layer anyways.
> How it comes?
> I want it to be in its own layer, but I only found ways to render text, 
> no way to save the ascii (or unicode) version of it.
> What am I missing?

gimp only works with its own text.  you could keep the text that you
would like to be rendered in a text file an

Re: [Gimp-user] How to write a "simple" macro [newbie]

2005-10-27 Thread michael chang
On 10/27/05, Mauro Condarelli <[EMAIL PROTECTED]> wrote:

> I need to:
> 1) Use the magic wand to select a region.
> 2) This region will be a big region with (possibly) internal sub-regions; if 
> this is the case I need to destroy all the inner regions (i.e.: I need to 
> preserve just the outer region, without any "holes").

Sounds like you're trying to erase the contents of a speech bubble and
fill it with new text.  The magic wand will select the white inside
the bubble (assuming it is actually closed, which isn't guaranteed in
comics, so you may get some bleeding which would ruin the entire
thing) but you'll have to delete the text by doing some sort of
combo-selection which will be kinda finicky.

> 3) Clear the region to a specified colour.
> 4) Edit a (possibly long) string and fit it into the cleared region 
> (eventually scaling the font to make it fit).
>
> Nice to have:
> - save the "original" region contents in a layer before killing it.
> - render the string to a different layer than the background (this would 
> enable to see either the "old" or the "new" content simply marking the two 
> layers visible/not-visible.

2.x text tools put text in a seperate layer...

> I need this in order to translate some comics I scanned.

Maybe you want to make a background later, select the area(s) with the
magic tool (click magic tool, shift click-click-click as necessary),
cut, paste in a new layer, hide the cutout's layer and then create a
text layer with your text.

I'm not sure if I'm being clear though, so it might not be helpful enough.

--
~Mike
 - Just my two cents
 - No man is an island, and no man is unable.
___
Gimp-user mailing list
Gimp-user@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user


Re: [Gimp-user] How to write a "simple" macro [newbie]

2005-10-27 Thread Carol Spears
On Thu, Oct 27, 2005 at 08:43:44AM -0700, Carol Spears wrote:
> On Thu, Oct 27, 2005 at 11:46:52AM +0200, Mauro Condarelli wrote:
> 
> > I want to automatise as much as possible the process. Doing it completely 
> > manually is impossibly long (for me).
> it will be much easier if you are needing to remove the same color
> region from each image.  one problem with doing things as you mentioned
> so far is that it might be very difficult to know where to pick the
> color from.
> 
some where, when i first typed this, i lost what i was trying to say.
Select by color would be better to use in automation.  it will find more
than one region though, if more than one exists on the image.

i wrote a script that used fuzzy selection on a directory of images. i
knew that i could pick from this one location and it would always work,
though.

carol

___
Gimp-user mailing list
Gimp-user@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user


Re: [Gimp-user] How to write a "simple" macro [newbie]

2005-10-27 Thread Carol Spears
On Thu, Oct 27, 2005 at 11:46:52AM +0200, Mauro Condarelli wrote:
> Hi,
> While I'm a reasonably seasoned programmer my experiece with graphics is in 
> the negative range, so, please, do not shot me on sight :) :)
> 
> I have a clear idea of What I need to do, but I'm unable to do it even 
> manually, let alone program a macro to automate the task :(
> 
the good news is (for you then) that gimp does not use macros.  this
means that you can use full-fledged computer languages to accomplish
what you need to.  gimp has enclosed a script-fu console and you have
access to a gimp python or perl module.

> I need to:
> 1) Use the magic wand to select a region.
> 2) This region will be a big region with (possibly) internal sub-regions; if 
> this is the case I need to destroy all the inner regions (i.e.: I need to 
> preserve just the outer region, without any "holes").

try to adjust the Threshold value in the tool options until you can
select the region that you are interested in.

> 3) Clear the region to a specified colour.

if you make the Toolbox background color into the selected color (and
you do not add an alpha channel to your image) Edit-->Clear, Edit-->Cut
or using the Eraser on the selection should "clear the region to a
specified colour".

> 4) Edit a (possibly long) string and fit it into the cleared region 
> (eventually scaling the font to make it fit).
> 
via scripts, there are many many ways to control text.  you can see this
if you look at Xtns-->PDB Browser and search for text.

> Nice to have:
> - save the "original" region contents in a layer before killing it.
work on a duplicate of the layer.  that would mean that you will need to
Edit--Fill your erased or cleared or cut region.  or perhaps put another
layer of the same color under the one you are working on.

> - render the string to a different layer than the background (this would 
> enable to see either the "old" or the "new" content simply marking the two 
> layers visible/not-visible.
> 
the text is on its own layer anyways.

> I need this in order to translate some comics I scanned.
each different color might need a different threshold setting.  

> I want to automatise as much as possible the process. Doing it completely 
> manually is impossibly long (for me).
it will be much easier if you are needing to remove the same color
region from each image.  one problem with doing things as you mentioned
so far is that it might be very difficult to know where to pick the
color from.

> Please remember that my graphics ability is zilch :(
> 
another thing to consider is gimp gap.


> P.S.: Please copy directly me; I tried to subscribe to the list, but I'm 
> unsure it worked (I didn't receive any message, yet).
> 
it is a tradition of this maillist.

carol

___
Gimp-user mailing list
Gimp-user@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user