Welcome, Guest |
You have to register before you can post on our site.
|
|
|
Gimp 3 Python Script - Merge Visible - No Flatten Image? |
Posted by: silenuznowan - 03-31-2025, 05:48 PM - Forum: Extending the GIMP
- Replies (6)
|
 |
Not sure if this is a problem with the documentation or if it's a bug, maybe someone here can shed some light.
I'm converting my Gimp 2 scripts to Gimp 3 and noticed that in v3 there is a new merge type listed in the docs for the description of:
gimp-image-merge-visible-layers
Under the parameters it lists:
Quote:The type of merge { EXPAND-AS-NECESSARY (0), CLIP-TO-IMAGE (1), CLIP-TO-BOTTOM-LAYER (2), FLATTEN-IMAGE (3) }, default EXPAND-AS-NECESSARY (0)
However calling gimp-image-merge-visible-layers , like so:
Code:
layer = merge_visible(img, Gimp.MergeType.FLATTEN_IMAGE)
Where merge_visible looks like this:
Code:
def merge_visible(image: Gimp.Image, merge_type: Gimp.MergeType = Gimp.MergeType.EXPAND_AS_NECESSARY)->Gimp.Layer:
"""
Merge the visible layers of an image into a single layer.
This procedure combines the visible layers into a single layer using the specified merge type.
A merge type of EXPAND_AS_NECESSARY expands the final layer to encompass the areas of the visible layers.
A merge type of CLIP_TO_IMAGE clips the final layer to the extents of the image.
A merge type of CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the bottommost layer.
:param image: Gimp image with the layers to be merged
:param merge_type: the type of merge:
0 = Expand as Necessary
1 = Clip to image
2 = clip to bottom
3 = Flatten Image
default = Expand as Necessary
:return: The merged layer
"""
procedure = Gimp.get_pdb().lookup_procedure('gimp-image-merge-visible-layers')
config = procedure.create_config()
config.set_property('image', image)
config.set_property('merge-type', merge_type)
result = procedure.run(config)
success = result.index(0)
layer = result.index(1)
return layer
However this results in an error:
Quote:GIMP-Error: Calling error for procedure 'gimp-image-merge-visible-layers':
Procedure 'gimp-image-merge-visible-layers' has been called with value 'GIMP_FLATTEN_IMAGE' for argument 'merge-type' (#2, type GimpMergeType). This value is out of range.
Thanks,
Jordan
|
|
|
David's Batch Processor i V3.0 |
Posted by: AfTech54 - 03-31-2025, 09:47 AM - Forum: Gimp 2.99 & Gimp 3.0
- Replies (2)
|
 |
I've used David's Batch Processor (Dbp) in v 2.10, the Dbp plugin appears in the Filter menu.
I've got the Dvp file in a MS OneDrive (OD) folder so I have access to my custom settings in my both computers.
Now I've added the (OD) folder to Settings/Folders/Plugins in V 3.0.2 but the plugin doesn't show up under the Filter menu.
I've also added the Dbp file to:
C:\Users\Roger\AppData\Local\Programs\GIMP 3\lib\gimp\3.0\plug-ins
C:\Users\Roger\OneDrive\Roger Private\OD GIMP Set\Custom\plug-ins
I've closed and started GIMP after each task.
Is the Dbp not compatible with Gimp 3, if so - is there any similar plugin working in V3.0?
|
|
|
resynthesizer |
Posted by: Gimper@PP - 03-31-2025, 09:26 AM - Forum: Extending the GIMP
- Replies (3)
|
 |
Hey, I use windows 11 + gimp 3.0.2 and i will install resynthesizer but i get it not install.
I get the last version of resynthsizer from github
I install it in preferences - map - plug-ins in gimp 3.0.2
What am i doing wrong?
|
|
|
Transforming an image? |
Posted by: Knusbrich - 03-30-2025, 06:31 PM - Forum: General questions
- Replies (1)
|
 |
First of all, I would like to mention that I am an absolute beginner in using GIMP.
I have a picture of a fence photographed from a drone. The fence looks like an ellipse in the picture, but in reality the fence is square. I have studied various videos on Youtube, but have not found one that helps me further. I imagine a kind of free transform tool where you can push and pull the frame of the picture in different places, so that the fence becomes more square. In short, it is described as changing an ellipse to a square. Does anyone have a link to a tutorial or a plugin that can help with this task?
|
|
|
Converseen batch image processor |
Posted by: denzjos - 03-30-2025, 07:09 AM - Forum: Other graphics software
- No Replies
|
 |
Converseen is a free cross-platform batch image processor for Windows, Linux, macOS, FreeBSD, and other operating systems. It allows you to convert, resize, rotate, and flip an infinite number of images with a single mouse click. Moreover, Converseen can convert an entire PDF document into a set of images with your preferred characteristics. You can choose from over 100+ formats, set the size, resolution, and the filename.
https://converseen.fasterland.net
|
|
|
Python Scripting Help Needed Gimp 3 |
Posted by: silenuznowan - 03-29-2025, 05:37 PM - Forum: Gimp 2.99 & Gimp 3.0
- Replies (1)
|
 |
I have some simple batch scripts for version 2 that I am trying to convert to work with version 3, which I really like working with.
Anyway one simple script was this:
Code:
import os
import gimpfu
def convert(filename):
img = pdb.gimp_file_load(filename, filename)
new_name = filename.rsplit(".",1)[0] + ".png"
layer = pdb.gimp_image_merge_visible_layers(img, 1)
pdb.gimp_file_save(img, layer, new_name, new_name)
pdb.gimp_image_delete(img)
savepath = ('${DEST}' + '/' + "$1" )
if os.path.exists(savepath):
print('the folder exists')
else:
os.makedirs(savepath)
os.rename(new_name, savepath + "/" + new_name)
from glob import glob
for filename in glob("*.xcf"):
print(filename)
convert(filename)
pdb.gimp_quit(1)
I'm now trying to do the equivalent with Gimp 3 but am unable to even load the file.
In Gimp 2 you could load a file with the one line:
Code:
img = pdb.gimp_file_load(filename, filename)
So now this is replaced with:
Code:
def load_file(filename):
procedure = Gimp.get_pdb().lookup_procedure('gimp-file-load');
config = procedure.create_config();
config.set_property('run-mode', Gimp.RunMode.NONINTERACTIVE);
config.set_property('file', filename);
result = procedure.run(config);
success = result.index(0);
image = result.index(1)
return image;
def convert(filename):
img = load_file(filename)
Only this results in the following error
Quote:TypeError: could not convert 'interior-starship-doors.xcf' to type 'GFile' when setting property 'GimpProcedureConfig-gimp-file-load.file'
So it looks like instead of expecting a filename for file the new python api expects an object of type GFile to be passed, and I was wondering how I do this?
Thanks in advance.
Update: I managed to figure things out using Gio so my new load_file function looks like this:
Code:
def load_file(filename):
file = Gio.File.new_for_path(filename)
procedure = Gimp.get_pdb().lookup_procedure('gimp-file-load');
config = procedure.create_config();
config.set_property('run-mode', Gimp.RunMode.NONINTERACTIVE);
config.set_property('file', file);
result = procedure.run(config);
success = result.index(0);
image = result.index(1)
return image;
While this works, I'm wondering if I'm also supposed to dispose of the Gio.File object, and if so how do I do that?
Thanks in advance. Also if there's any interest I can post the whole version of the new script.
|
|
|
|