Using 2.6.8 on Linux.
--
Illustrated post highlighting Linux features, e.g., desktop cube, on KDE/Kubuntu
"A Linux user wonders, can Windows do this?" http://tinyurl.com/25t4mn9
> Is there a way to specify an exact location when pasting an object?
> Perhaps using pixels as coordinates? Say I wanted an object to be placed
> so its right edge is at 3000 pixels across and its bottom is at 2500
> pixels down, how could I do this?
>
> Using 2.6.8 on Linux.
Maybe use some guides. Set at the required coordinates in 'image' ->
'guides' -> 'new guide'. Make sure 'snap to guide' is on 'view' -> 'snap
to guides'. Selection will snap to the intersection of the guides.
--
rich
Thanks, Rich. I should have been clearer. I'm doing it the guide way right now;
what I want is a way to do it without having to set up guides first. Hence the
idea of using coordinates somehow.
Paste has several variations: paste, paste as [new image], paste into, etc. So
I'm thinking along the lines of "paste into, at XYZ,ABC" where XYZ and ABC are
the coordinates in pixels.
> rich wrote:
>> On Sat, 04 Dec 2010 20:34:57 -0800, pacific coast wrote:
>>
>>> Is there a way to specify an exact location when pasting an object?
>>> Perhaps using pixels as coordinates? Say I wanted an object to be
>>> placed so its right edge is at 3000 pixels across and its bottom is at
>>> 2500 pixels down, how could I do this?
>>>
>>> Using 2.6.8 on Linux.
>
>> Maybe use some guides. Set at the required coordinates in 'image' ->
>> 'guides' -> 'new guide'. Make sure 'snap to guide' is on 'view' ->
>> 'snap to guides'. Selection will snap to the intersection of the
>> guides.
>
> Thanks, Rich. I should have been clearer. I'm doing it the guide way
> right now; what I want is a way to do it without having to set up guides
> first. Hence the idea of using coordinates somehow.
>
> Paste has several variations: paste, paste as [new image], paste into,
> etc. So I'm thinking along the lines of "paste into, at XYZ,ABC" where
> XYZ and ABC are the coordinates in pixels.
don't know
you could save as 2 images and use imagemagick
composite -geometry +100+150 1.png 2.png 3.png
the co-ords are the top LH corner
--
rich
Assuming you have the desired object in the clipboard...
IMAGE->Edit->Paste as->New layer
That should create a new layer, which will be the top
layer and will be the current layer and will have the
clipboard object located a 0,0. Then double click
on the Toolbox icon for "Move Tool", which will bring up
the dialog box for the Move Tool. Select the option to
move the active layer. Then position the cursor at
location 0,0, hold down the left mouse button and drag
the layer to whatever location you which to place the
object, and release the mouse button.
You can then merge layers or whatever.
--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) fl...@apaflo.com
> Assuming you have the desired object in the clipboard...
>
> IMAGE->Edit->Paste as->New layer
>
> That should create a new layer, which will be the top
> layer and will be the current layer and will have the
> clipboard object located a 0,0. Then double click
> on the Toolbox icon for "Move Tool", which will bring up
> the dialog box for the Move Tool. Select the option to
> move the active layer. Then position the cursor at
> location 0,0, hold down the left mouse button and drag
> the layer to whatever location you which to place the
> object, and release the mouse button.
>
> You can then merge layers or whatever.
Thanks, Floyd. As I said to Rich in another reply, I should have been clearer.
I'm looking for a way to do it without having to manually do anything (set up
guides, drag the object, whatever). Hence the idea of using coordinates somehow.
Paste has several variations: paste, paste as [new image], paste into, etc. So
I'm thinking along the lines of "paste into, at XYZ,ABC" where XYZ and ABC are
the coordinates in pixels.
I love ImageMagick and always use it when I have hundreds [or thousands] of
images to process. The task I'm posting about doesn't lend itself to IM, because
I have to see the result, decide whether it's okay where it ended up (it's a
line of floating text and I have two versions, in different colors; if the first
isn't easily readable in its destination, then I undo it and paste in the other
one), and possibly tweak its placement.
Those are the steps required to accomplish the task. No
matter how you approach it, you necessarily have to
"manually do" something.
What you appear to be asking for is a way to reduce it
to a *single* manual command, while what I've provided
is a set of multiple primatives that can be used in
combination to make such a single command.
You can uses Script-Fu (scheme) or Python-Fu (python) to
write a script, though it only translates from the listed
commands on a conceptual basis, and the script commands
to implement the same concept will not be identical.
Below is a Python script that I threw together to test the
idea. This is *not* a polished well thought out script!
It's a start...
#!/usr/bin/env python
##########################################################################
#
# pastexy.py -- Paste the clipboard at location X,Y
#
##########################################################################
#
# Copyright 2010 by Floyd L. Davidson, fl...@apaflo.com
#
##########################################################################
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##########################################################################
from gimpfu import *
def python_pastexy(image, layer, x, y):
def paste_xy(x, y):
original_layer = pdb.gimp_image_get_active_layer(image)
clipbrd = pdb.gimp_layer_copy(original_layer, FALSE)
pdb.gimp_image_add_layer(image, clipbrd, -1)
pdb.gimp_image_set_active_layer(image, clipbrd)
pdb.gimp_selection_all(image)
pdb.gimp_edit_clear(clipbrd)
fltsel = pdb.gimp_edit_paste(clipbrd, TRUE)
pdb.gimp_floating_sel_anchor(fltsel)
clipbrd = pdb.gimp_image_get_active_layer(image)
pdb.plug_in_autocrop_layer(image, clipbrd)
offset_x, offset_y = pdb.gimp_drawable_offsets(clipbrd)
pdb.gimp_layer_translate(clipbrd, x - offset_x, y - offset_y)
#
# Process image
#
image.undo_group_start()
paste_xy(x, y)
image.undo_group_end()
register(
"python_fu_pastexy",
"Paste Clipboard at lcoation X,Y",
"Paste Clipboard at lcoation X,Y",
"Floyd Davidson",
"GPL",
"2010",
"<Image>/Python-Fu/Pastexy",
"*",
[
(PF_INT, "x", "Horizontal Co-ordinate", 100),
(PF_INT, "y", "Vertical Co-ordinate", 200),
],
[],
python_pastexy)
main()
I have a Python script which I use to put titles on
images. It does two lines of text (and can center the
shorter line in relation to the longer one). The font,
color and size are selected per line. It has selectable
options to place the lines at the center, left side or
right side, top or bottom. It can also place the lines
dead center, and in that case can rotate the lines too
(which with offsets means it can be place at either the
right or left edge).
It might be that this script does everything you are
trying to accomplish? It doesn't use the clipboard at
all, and requires that you manually type in the text for
each line (I have defaults of course, and it also
recognizes things such as %D for the date, %Y for the
year, %f for the file name, etc).
I could post it, it's maybe 400 lines or so.
> The task I'm posting about doesn't lend itself to IM, because I have to
> see the result, decide whether it's okay where it ended up (it's a line of
> floating text and I have two versions, in different colors; if the first
> isn't easily readable in its destination, then I undo it and paste in the
> other one), and possibly tweak its placement.
A job for Inkscape rather than Gimp?
Here's a more polished version. This puts the menu
option into the "<Image>->Edit->Paste as" menu. It has
the option to flatten or not, and if not the new layer
can be named. But most important is that it correctly
clears the new layer to transparency, thus allowing
irregular shaped objects to be inserted without a
rectangular area of foreground color. The new layer is
also resized to match the image. The clipboard object
can also be rotated and scaled.
This appears to be a useful functionality. Any
additional ideas would be welcome. But it is still alpha
level code, as I've done little more than determine that
it can do what I wanted it to do. It might do all sorts
of things that I haven't discovered yet!
#!/usr/bin/env python
##########################################################################
#
# pastexy.py -- Paste the clipboard at location X,Y
#
##########################################################################
#
# Copyright 2010 by Floyd L. Davidson, fl...@apaflo.com
# File created: Sun Dec 5 11:33:44 2010
# Last updated: Mon Dec 6 04:51:17 2010
#
##########################################################################
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##########################################################################
from gimpfu import *
def python_pastexy(image, layer, x, y, rotate, zoom, flat, name):
def paste_xy(name, x, y):
pdb.gimp_selection_all(image)
original_layer = pdb.gimp_image_get_active_layer(image)
clipbrd = pdb.gimp_layer_copy(original_layer, True)
pdb.gimp_image_add_layer(image, clipbrd, -1)
pdb.gimp_image_set_active_layer(image, clipbrd)
pdb.gimp_edit_clear(clipbrd)
wrklayer = pdb.gimp_edit_paste(clipbrd, True)
pdb.gimp_floating_sel_anchor(wrklayer)
clipbrd = pdb.gimp_image_get_active_layer(image)
pdb.plug_in_autocrop_layer(image, clipbrd)
if rotate != 0:
pdb.gimp_selection_all(image)
clipbrd = pdb.gimp_image_get_active_layer(image)
r = math.radians(rotate)
centerx = clipbrd.width / 2
centery = clipbrd.height / 2
wrklayer = pdb.gimp_drawable_transform_rotate_default(clipbrd, r, 1, centerx, centery, 1, 0)
clipbrd = pdb.gimp_image_get_active_layer(image)
clipbrd = pdb.gimp_image_get_active_layer(image)
x1 = clipbrd.width
y1 = clipbrd.height
realzoom = math.sqrt(zoom)
if zoom > 1.05:
y1 = y1 * realzoom
x1 = x1 * realzoom
pdb.gimp_layer_scale(clipbrd, x1, y1, True)
if zoom < 0.95:
y1 = y1 * realzoom
x1 = x1 * realzoom
pdb.gimp_layer_scale(clipbrd, x1, y1, True)
offset_x, offset_y = pdb.gimp_drawable_offsets(clipbrd)
pdb.gimp_layer_translate(clipbrd, x - offset_x, y - offset_y)
pdb.gimp_layer_resize_to_image_size(clipbrd)
clipbrd = pdb.gimp_image_get_active_layer(image)
pdb.gimp_drawable_set_name(clipbrd, name)
if rotate != 0:
pdb.gimp_image_remove_layer(image, wrklayer)
if flat == True:
pdb.gimp_image_flatten(image)
#
# Process image
#
image.undo_group_start()
paste_xy(name, x, y)
image.undo_group_end()
register(
"python_fu_pastexy",
N_("Paste Clipboard at location X,Y"),
"""Paste Clipboard into new layer at location X,Y""",
"Floyd Davidson",
"GPL",
"2010",
N_("New Layer at location X,Y"),
"*",
[
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "layer", "Input drawable", None),
(PF_INT, "x", "Horizontal Coordinate", 0),
(PF_INT, "y", "Vertical Coordinate", 0),
(PF_INT, "rotate", "Rotate +/- degrees", 0),
(PF_FLOAT, "zoom", "Zoom", 1.00),
(PF_BOOL, "flat", "Flatten Image?", False),
(PF_STRING, "name", "Name of New Layer", "Clipboard Object"),
],
[],
python_pastexy,
menu="<Image>/Edit/Paste as",
domain=("gimp20-python", gimp.locale_directory))
> fl...@apaflo.com (Floyd L. Davidson) wrote:
>>
>>Below is a Python script that I threw together to test the idea. This
>>is *not* a polished well thought out script! It's a start...
>
> Here's a more polished version. This puts the menu option into the
> "<Image>->Edit->Paste as" menu. It has the option to flatten or not,
> and if not the new layer can be named. But most important is that it
<snip>
>
##########################################################################
> #
> # pastexy.py -- Paste the clipboard at location X,Y #
>
##########################################################################
> #
> # Copyright 2010 by Floyd L. Davidson, fl...@apaflo.com # File
> created: Sun Dec 5 11:33:44 2010 # Last updated: Mon Dec 6 04:51:17
> 2010 #
>
##########################################################################
<snip>
That is very very good and makes you wonder why there was nothing similar
existing in gimp. Its is working fine here in PCLOS2010 & Gimp 2.6.11
Thank you for a new tool.
--
rich
I kinda liked the idea too once I understood exactly
what the OP wanted. The only problem I have with it
right now is that I can't put the menu item exactly
where I want it in the "Paste as" menu list. Oh well...
But for the OP, it really isn't the best tool to put or
move text in an image. I use a different Python script
for that and from the description it would be a near
perfect fit. Except it has some fun things that I can't
test under Windows, and I don't know if it just bombs,
doesn't produce the desired results, or acts like it is
supposed to. It gets the Create Date from Exif data
under Linux, using exiftool. It might just not find the
date and default to the current date, which is what it
does under Linux if the Exif data doesn't exist in the
image file.
I've put that file in a place where it can be
downloaded:
<http://web.newsguy.com/floyd_davidson/gimp/signature.py>.
Thank you so much for taking the time to do this! And--obviously--I agree that
it's a useful functionality. :)
Once I've had a chance to play with it a bit more I'll post if there's anything
I think of that could be added/tweaked.
Again, thanks. It's definitely appreciated.
--
Illustrated post highlighting Linux features, e.g., desktop cube, on KDE/Kubuntu
Hmmmm...I've really never used Inkscape, although I've installed it in the past.
I may need to take a look at it...