Gimp-Forum.net
Newbie : need help to do a mosaic from tiles - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Newbie : need help to do a mosaic from tiles (/Thread-Newbie-need-help-to-do-a-mosaic-from-tiles)



Newbie : need help to do a mosaic from tiles - franco1000 - 04-02-2021

Hello, i'am a newbie ( and a dummy).
I have a small experience in python scripting ( 3d cad Rhinoceros), no experience with Gimp. I would make a script to made a mosaic of tiles. For this i need to do several times this loop:

import a jpg picture as layer
move  it in a specific position
crop it whit a rectangular selection
verify that the layer is in the right position in the stack of the layers.

I tried to visit some sites and the posts in this Forum, but I was not able to have a general idea of the classes and the methods and the procedures to load , show , move and crop a picture.

May I have some help'?

Franco1000


RE: Newbie : need help to do a mosaic from tiles - Ofnuts - 04-02-2021

(04-02-2021, 02:49 PM)franco1000 Wrote: Hello, i'am a newbie ( and a dummy).
I have a small experience in python scripting ( 3d cad Rhinoceros), no experience with Gimp. I would make a script to made a mosaic of tiles. For this i need to do several times this loop:

import a jpg picture as layer
move  it in a specific position
crop it whit a rectangular selection
verify that the layer is in the right position in the stack of the layers.

I tried to visit some sites and the posts in this Forum, but I was not able to have a general idea of the classes and the methods and the procedures to load , show , move and crop a picture.

May I have some help'?

Franco1000

Get my ofn-tiles script from here. It should get you started (if not already everything you want). Come back here for questions.


RE: Newbie : need help to do a mosaic from tiles - franco1000 - 04-05-2021

Thank Ofnuts , it is helpful . I shall ask you something more later.
Franco 1000


RE: Newbie : need help to do a mosaic from tiles - franco1000 - 04-10-2021

Hello ,
I moved layer A partially over the Layer B: They are superimposed so I must crop a slice of A ( or B). I tryed to make a python script using the method " pdb.gimp_layer_resize".
But i had only bizzare results not corresponding to the instruction of the Python console help.
A bug exists, i don't know if in the procedure or in me.
Some suggestions?

Thank you,
Franco


RE: Newbie : need help to do a mosaic from tiles - Ofnuts - 04-10-2021

(04-10-2021, 02:32 PM)franco1000 Wrote: Hello ,
I moved  layer A partially over the Layer B:  They are superimposed  so I must crop a slice of A ( or B). I tryed to make a python script using the method " pdb.gimp_layer_resize".
But i had only bizzare results not corresponding to the instruction of the Python console help.
A bug exists, i don't know if in the procedure or in me.
Some suggestions?

Thank you,
Franco

When layers overlap you don't need to do anything if they are fully opaque, as long as they are in the right order in the stack.

Otherwise pdb.gimp_layer_resize() (or more simply layer.resize()) works OK, but the way it is defined (old-new), if you want to select an area inside the layer the offsets to provide are negative. For instance, to get the green area from the red area, you use:

[attachment=5851]

Code:
layer.resize(100,200,-150,-50)
PS: after a long career in programming, I can assure you that most of the time you find that the problem is with your code(*). I have started many bug reports that eventually ended in the bit bucket because while make sure that my case was watertight I found the problem in my ways.
(*) when it's your code v.s. a generally available piece of code: compiler, API... When it's your code v.s. a coworker's code, it's a more of a gamble of who will eventually pay the "hop tax" at a nearby bar (I don't lose often these days).


RE: Newbie : need help to do a mosaic from tiles - franco1000 - 04-11-2021

Thank you very much! Is was so easy...