| Welcome, Guest |
You have to register before you can post on our site.
|
| Forum Statistics |
» Members: 4,998
» Latest member: Aaronnef
» Forum threads: 7,738
» Forum posts: 42,060
Full Statistics
|
| Latest Threads |
Path autocurves plugin (G...
Forum: Extending the GIMP
Last Post: InquisitiveAsHell
12-13-2025, 05:35 PM
» Replies: 4
» Views: 444
|
Help with colour matching
Forum: General questions
Last Post: denzjos
12-13-2025, 05:05 PM
» Replies: 1
» Views: 138
|
Problem posting an update...
Forum: Gimp-Forum.net
Last Post: Scallact
12-13-2025, 10:29 AM
» Replies: 14
» Views: 372
|
GIMP 3.x Python Plugin Is...
Forum: Scripting questions
Last Post: Ofnuts
12-13-2025, 08:53 AM
» Replies: 1
» Views: 143
|
Gimp larger than Screen
Forum: General questions
Last Post: sallyanne
12-13-2025, 03:53 AM
» Replies: 2
» Views: 200
|
Straighten your image bef...
Forum: General questions
Last Post: ESH
12-12-2025, 09:26 PM
» Replies: 4
» Views: 196
|
Can't Find where to insta...
Forum: OSX
Last Post: rich2005
12-12-2025, 10:21 AM
» Replies: 1
» Views: 148
|
Transparent Background Ad...
Forum: General questions
Last Post: sallyanne
12-12-2025, 02:27 AM
» Replies: 1
» Views: 174
|
Gimp exports TIFFs with s...
Forum: General questions
Last Post: ESH
12-12-2025, 12:34 AM
» Replies: 4
» Views: 340
|
an iOS app that assists p...
Forum: Other graphics software
Last Post: zzh
12-11-2025, 01:06 PM
» Replies: 4
» Views: 371
|
|
|
| GIMP 3.x Python Plugin Issue: Reliable Program Exit and Image Closing |
|
Posted by: not_a_real_gimp - 12-12-2025, 11:26 AM - Forum: Scripting questions
- Replies (1)
|
 |
Hello GIMP Community,
I am facing an issue in a GIMP 3.0 Python plugin: reliably closing the program and the last active image when the sequential workflow is finished.
My script is running in the GUI Mode, and I need to perform two actions in order:
- Close the last open image container.
- Force GIMP to quit the application entirely.
The old methods from v2 do not work anymore and I am unsure if what I am trying to achieve is actually possible.
Here is my script so far (German annotations):
Code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import gi
gi.require_version('Gimp', '3.0')
gi.require_version('GimpUi', '3.0')
from gi.repository import Gimp, GimpUi, GObject, GLib, Gio
import os
import json
import tempfile
import traceback
# Pfad für die temporäre Konfigurationsdatei
CONFIG_PATH = os.path.join(tempfile.gettempdir(), 'gimp_spore_workflow_config.json')
class ExportAndNextWorkflow(Gimp.PlugIn):
def do_query_procedures(self):
return ['python-fu-export-and-next']
def do_set_i18n(self, procname):
return False, 'gimp30-python', None
def do_create_procedure(self, name):
procedure = Gimp.ImageProcedure.new(
self, name,
Gimp.PDBProcType.PLUGIN,
self.run, None
)
procedure.set_image_types("*")
procedure.set_sensitivity_mask(Gimp.ProcedureSensitivityMask.DRAWABLE)
procedure.set_menu_label("1. Exportieren & Nächstes Bild")
procedure.add_menu_path('<Image>/Auswahl/')
procedure.set_documentation(
"Exportiert die Auswahl, speichert W/H und lädt das nächste Bild.",
"Exportiert die aktuelle Auswahl und bereitet den nächsten Schritt vor.",
name
)
procedure.set_attribution("Author", "Author", "2024")
return procedure
# --- HILFSFUNKTIONEN ---
def load_config(self):
if os.path.exists(CONFIG_PATH):
try:
with open(CONFIG_PATH, 'r') as f:
return json.load(f)
except:
pass
return None
def save_config(self, width, height, current_path=None):
data = {'width': int(width), 'height': int(height)}
try:
existing_data = self.load_config()
if existing_data:
data.update(existing_data)
if current_path is not None:
data['last_path'] = current_path
with open(CONFIG_PATH, 'w') as f:
json.dump(data, f, indent=4)
except Exception as e:
pass
def get_next_file(self, current_path):
directory = os.path.dirname(current_path)
basename = os.path.basename(current_path)
extensions = ('.jpg', '.jpeg', '.png', '.tif', '.tiff', '.xcf')
files = [f for f in os.listdir(directory) if f.lower().endswith(extensions)]
files.sort()
try:
index = files.index(basename)
if index + 1 < len(files):
return os.path.join(directory, files[index + 1])
except ValueError:
pass
return None
# --- HAUPT-RUN-FUNKTION ---
def run(self, procedure, run_mode, image, n_drawables, drawables, config, run_data=None):
# 0. Initialisierung & Auswahlprüfung
selection = image.get_selection()
success, non_empty, x1, y1, x2, y2 = selection.bounds(image)
if not non_empty:
error = GLib.Error.new_literal(Gimp.PlugIn.error_quark(), "Keine Auswahl vorhanden.", 0)
return procedure.new_return_values(Gimp.PDBStatusType.CALLING_ERROR, error)
target_w = x2 - x1
target_h = y2 - y1
# 1. Pfad ermitteln
current_path = None
current_file = image.get_file()
if current_file is not None:
current_path = current_file.get_path()
else:
config_data = self.load_config()
if config_data and 'last_path' in config_data:
current_path = config_data['last_path']
if current_path is None:
error = GLib.Error.new_literal(Gimp.PlugIn.error_quark(),
"Bild hat keinen Dateipfad (Konfiguration leer).", 0)
return procedure.new_return_values(Gimp.PDBStatusType.EXECUTION_ERROR, error)
directory = os.path.dirname(current_path)
basename = os.path.splitext(os.path.basename(current_path))[0]
# Zielordner für Exporte definieren
target_dir = os.path.join(directory, "Auswahlen")
# --- TEIL A: EXPORTIEREN ---
try:
# 2. Zielordner erstellen (falls nicht vorhanden)
if not os.path.exists(target_dir):
os.makedirs(target_dir)
# 3. Nächste freie Export-Nummer finden (suche im Zielordner)
number = 1
while True:
new_filename = f"[{number}] {basename}.jpg"
new_filepath = os.path.join(target_dir, new_filename)
if not os.path.exists(new_filepath):
break
number += 1
# 4. Auswahl kopieren, neues Bild erstellen, speichern
drawable = image.get_layers()[-1]
Gimp.edit_copy([drawable])
new_image = Gimp.edit_paste_as_new_image()
# Speichere direkt in den Auswahlen-Ordner
new_file = Gio.file_new_for_path(new_filepath)
Gimp.file_save(Gimp.RunMode.NONINTERACTIVE, new_image, new_file)
new_image.delete()
# 5. Auswahlgröße speichern (für Script 2)
self.save_config(target_w, target_h)
except Exception as e:
if 'new_image' in locals():
try: new_image.delete()
except: pass
error_msg = f"Fehler beim Export: {str(e)}\n{traceback.format_exc()}"
error = GLib.Error.new_literal(Gimp.PlugIn.error_quark(), error_msg, 0)
return procedure.new_return_values(Gimp.PDBStatusType.EXECUTION_ERROR, error)
# --- TEIL B: NÄCHSTES BILD LADEN (MIT ENDPRÜFUNG) ---
# 6. Nächstes Bild ermitteln
next_path = self.get_next_file(current_path)
if not next_path:
# ENDE DER SEQUENZ ERREICHT!
# Letzten Pfad zurücksetzen.
self.save_config(target_w, target_h, current_path=None)
# Aktuelles Bild aus der Anzeige entfernen
image.delete()
# GIMP 3.0 Methode zum Aufruf der PDB-Prozedur "gimp-quit"
try:
# Korrektur: Verwendung von Gimp.TYPE_INT anstelle von GObject.TYPE_INT
Gimp.plug_in_manager_run(
"gimp-quit",
Gimp.RunMode.NONINTERACTIVE,
GObject.Value.new(Gimp.TYPE_INT, 0)
)
except Exception as e:
Gimp.message(f"WARNUNG: GIMP 3.0 Quit-Aufruf fehlgeschlagen: {str(e)}")
# Korrigierter Rückgabestatus:
return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, None)
try:
# 7. Normaler Ablauf: Bild laden und Pfad speichern
new_gfile = Gio.file_new_for_path(next_path)
new_image = Gimp.file_load(Gimp.RunMode.NONINTERACTIVE, new_gfile)
self.save_config(target_w, target_h, current_path=next_path)
# 8. Anzeige erstellen und altes Bild schließen
Gimp.Display.new(new_image)
image.delete()
Gimp.displays_flush()
except Exception as e:
error_msg = f"Fehler beim Wechseln: {str(e)}\n{traceback.format_exc()}"
error = GLib.Error.new_literal(Gimp.PlugIn.error_quark(), error_msg, 0)
return procedure.new_return_values(Gimp.PDBStatusType.EXECUTION_ERROR, error)
# Korrigierter Rückgabestatus:
return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, None)
Gimp.main(ExportAndNextWorkflow.__gtype__, sys.argv)
Does anyone have an idea whether what I am trying to do is possible?
|
|
|
| Gimp larger than Screen |
|
Posted by: sallyanne - 12-12-2025, 07:39 AM - Forum: General questions
- Replies (2)
|
 |
I have restarted it and checked preferences incase they got changed.
I cannot see the status bar on the bottom of gimp or the bottom of my dialogs that are at the bottom.
It originally did what I wrote above when I opened it today. After restarting I can barely see the top menu bar and the bar above where it has the image name.
What is wrong - what should I do?
Oh, my version is 3.0.4 portable clang. This only happened today
EDIT:- I was able to pull it down to see the top bar so I could turn it off again
EDIT x2:- Opened it again and all is ok now while Gimp is maximised. When I minimise it A few things I cannot see still, like the bottom status bar and bottom of dialogs along the bottom of Gimp
|
|
|
| Can't Find where to install Local Help Manual |
|
Posted by: scastle - 12-12-2025, 02:42 AM - Forum: OSX
- Replies (1)
|
 |
Im on a Mac and I just installed Gimp 3. And it states The GIMP user manual is not installed in your language."
"You may either install the additional help package or change your preferences to use the online version."
but the only English manual I see is a windows .exe installer, Where's an English Mac version?
Thanks
Steve
|
|
|
| Transparent Background Adds to Dimensions of Exported PNG |
|
Posted by: Kramskry - 12-11-2025, 04:15 PM - Forum: General questions
- Replies (1)
|
 |
Hi Everyone,
I have been trying to figure this out for 2 days, and have come up short, so I created an account to hopefully get some help. I am new to GIMP and have been using it to extract a little image from a larger image. I use Linux Mint Cinnamon.
I extracted the image, added an alpha layer, made the background transparent, and extracted my image as a PNG with the "save background color" option unchecked. The png properly shows only the image in the thumbnail of my file browser (no background), but when I right click on the file and view the properties it shows the total width x height of the file as including the transparent background from the canvas in GIMP. To illustrate, the image is roughly 360x350 pixels, but the total W x H is 1344x768.
The problem arises because I want to change the image size, but when I try to scale it GIMP scales based on the size of the canvas, not the size of the image. I found a workaround where I changed the Canvas Size to match roughly what the image is, so then when I use Scale Image my actual image is closer to what I want. There is still a small amount of error in this method because the whole canvas size is slighly bigger than my image.
Is there an an answer to my question? I spent so much time searching, but all I could find was people with problems of a background showing in their exported images and badly written ai articles outlining bare minimum basics. I went through the GIMP documentation, but I didn't see any mentioned regarding file dimensions and how they work when exporting with GIMP. To me, it seems like a transparent background would not be included in dimensions of a PNG because it does not exist. Maybe it does exist and the dimensional data is included in the file itself, but not rendered when used? I think I am fundamentally misunderstanding something.
Is the solution I came up with the best way to accomplish what I need?
|
|
|
| help with running an scm script as batch from bash |
|
Posted by: DanielMalaga - 12-10-2025, 03:15 PM - Forum: Scripting questions
- Replies (2)
|
 |
Hello,
with Gimp 2.8 I have an scm script (I found somewhere) that runs perfect on one image when called from the menu within gimp. Now I'd like to run it for a whole directory and wrote a bash script for this.
It works in general, but when running the script on a single image within the Gimp, it creates a group with two layers and places this group above the original image layer. But when running it as a batch with my bash script, the original image layer is inserted within the new group.
Neither grok nor chat gpt could help me successfully :-)
Can you hint me what to change, so that the original image layer stays as a separate layer outside (below) the new layer-group?
(B.t.w., I have literally no idea of Gimp scripting, am just capable to use and adapt a little scripts I find somewhere :-) )
This is my bash script:
Code:
#!/bin/bash
INPUT_DIR="..."
OUTPUT_SUFFIX=".xcf"
BLUR=15
VISIBLE="FALSE"
for file in "$INPUT_DIR"/*.{jpg,png,tif,bmp}; do
if [ -f "$file" ]; then
output_file="${file%.*}${OUTPUT_SUFFIX}"
gimp -i -b "
(let*
(
(filename \"$file\")
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
;; Bottom layer = original image
(layer-info (gimp-image-get-layers image))
(drawable (vector-ref (cadr layer-info) 0))
;; Extract name
(fname (car (reverse (strbreakup filename \"/\"))))
(basename (car (strbreakup fname \".\")))
)
;; Rename to match GUI
(gimp-item-set-name drawable basename)
;; select this layer before FS script
(gimp-image-set-active-layer image drawable)
;; Run FS
(script-fu-hk-frequency-separation image drawable $BLUR $VISIBLE)
;; Save
(gimp-xcf-save RUN-NONINTERACTIVE image drawable \"$output_file\" \"$output_file\")
(gimp-image-delete image)
)
" -b '(gimp-quit 0)'
echo "Processed: $file -> $output_file"
fi
done
This is the scm script:
Code:
; This plugin was tested with Gimp 2.8.3
; This plugin will not work for Gimp 2.6.x because of the unknown layer group
;
; frequency-separartion.scm
; seperates a layer or the whole visible into a
; layer group with high- and low frequency parts
;
; 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., 675 Mass Ave, Cambridge, MA 02139, USA.
;
(define LList '())
(define (makelist E) (list E))
(define (isempty L) (null? L))
(define (add E L) (cons E L))
(define (Ith i L)
(if (= i 1)
(car L)
(Ith (- i 1) (cdr L))))
(define (fs-set-layers-visible inImage)
(let*
(
(num-layers (length LList))
(theLayer 0)
)
(while (> num-layers 0)
(set! theLayer (Ith num-layers LList))
(gimp-drawable-set-visible theLayer TRUE)
(set! num-layers (- num-layers 1))
)
; (gimp-displays-flush)
(set! LList (list))
)
)
(define (fs-set-layers-invisible inImage inLayer)
(let*
(
(layers (gimp-image-get-layers inImage))
(num-layers (car layers))
(layer-array (cadr layers))
(theLayer 0)
)
(while (> num-layers 0)
(set! num-layers (- num-layers 1))
(set! theLayer (vector-ref layer-array num-layers))
(if (= (car (gimp-drawable-get-visible theLayer) ) TRUE)
(if (<> theLayer inLayer)
(begin
(gimp-drawable-set-visible theLayer FALSE)
(set! LList (cons theLayer LList))
)
)
)
)
; (gimp-displays-flush)
)
)
(define (script-fu-hk-frequency-separation image layer blur visible)
(let*
(
; test, whether seperating a layer group
(isgroup (car (gimp-item-is-group layer)))
; get parent, maybe layer group
(parent (car (gimp-item-get-parent layer)))
; get layername
(layername (car (gimp-item-get-name layer)))
; gets position of layer
(position (car (gimp-image-get-item-position image layer)))
; creates layergroup
(fs-layergroup (car (gimp-layer-group-new image)))
; variables
(helplayer 0)
(lowlayer 0)
(highlayer 0)
(forceVisible 0)
(viewmode 0)
(opacity 0)
)
; FALSE=freqsep just the layer
; TRUE=freqsep from new visible
(if (= visible FALSE)
(begin
(if (= isgroup 1)
(begin
(set! forceVisible 1)
)
(begin
(set! forceVisible 0)
)
)
)
(begin
(set! forceVisible 1)
)
)
(gimp-image-undo-group-start image)
(if (= forceVisible 0)
(begin
(fs-set-layers-invisible image layer)
)
)
;rename layergroup
(gimp-item-set-name fs-layergroup "frequency separation")
;add layergroup as first to the image layer-stack
(gimp-image-insert-layer image fs-layergroup 0 0)
; 0=freqsep just the layer
; 1=freqsep from new visible
(if (= forceVisible 0)
(begin
(set! viewmode (car (gimp-layer-get-mode layer)))
(set! opacity (car (gimp-layer-get-opacity layer)))
(gimp-image-reorder-item image layer fs-layergroup -1)
(gimp-layer-set-mode layer NORMAL-MODE)
(gimp-layer-set-opacity layer 100)
(set! helplayer (car (gimp-layer-copy layer 1)))
(set! lowlayer (car (gimp-layer-copy layer 1)))
(gimp-drawable-set-name helplayer (string-append "help-" layername))
(gimp-drawable-set-name lowlayer (string-append "low-" layername))
)
(begin
(set! helplayer (car (gimp-layer-new-from-visible image image "helplayer")))
(set! lowlayer (car (gimp-layer-new-from-visible image image "low")))
)
)
; adding layers to layergroup
(gimp-image-insert-layer image helplayer fs-layergroup -1)
(gimp-image-insert-layer image lowlayer fs-layergroup -1)
; despeckle the low frequency layer
(plug-in-gauss 1 image lowlayer blur blur 1)
; setting layer mode to get the high frequency layer
(gimp-layer-set-mode lowlayer GRAIN-EXTRACT-MODE)
; getting the high frequency layer. that works, because the lauergroup is topmost
(set! highlayer (car (gimp-layer-new-from-visible image image (string-append "high-" layername))))
; add it it to the layergroup
(gimp-image-insert-layer image highlayer fs-layergroup -1)
; remove the helping layer
(gimp-image-remove-layer image helplayer)
; make the low frequency layer normal
(gimp-layer-set-mode lowlayer NORMAL-MODE)
; make the high frequency layer grain-merge, so the result is the image
(gimp-layer-set-mode highlayer GRAIN-MERGE-MODE)
; put the layergroup just above the layer, that was selected
(gimp-image-reorder-item image fs-layergroup parent position)
(if (= forceVisible 0)
(begin
; restore viewmode and opacity, now for the whole layergroup.
(gimp-layer-set-mode fs-layergroup viewmode)
(gimp-layer-set-opacity fs-layergroup opacity)
(fs-set-layers-visible image)
)
)
(gimp-image-set-active-layer image lowlayer)
(gimp-displays-flush)
(gimp-image-undo-group-end image)
)
)
(script-fu-register "script-fu-hk-frequency-separation"
"Frequency separation..."
"frequency-separation.scm
divides layer in high and low frequencies"
"H.Kuhse"
"H.Kuhse"
"2013-01-04"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0
SF-ADJUSTMENT _"Blur:" '(15 1 50 1 1 0 0)
SF-TOGGLE _"from visible (instead selected layer)" 1
)
(script-fu-menu-register
"script-fu-hk-frequency-separation"
"<Image>/Filters"
)
|
|
|
| Problems with AppImages. |
|
Posted by: teapot - 12-08-2025, 07:01 PM - Forum: Installation and usage
- Replies (1)
|
 |
From https://download.gimp.org/gimp/v3.0/linux/
I find these AppImages work fine here:
GIMP-3.0.0-aarch64.AppImage
GIMP-3.0.2-aarch64.AppImage
GIMP-3.0.4-aarch64.AppImage
But these two later ones suffer the same problems:
GIMP-3.0.6-aarch64.AppImage
GIMP-3.2.0-RC1-aarch64.AppImage
When running 3.0.6, the first error printed seems the key one:
(gimp:12345): Gtk-CRITICAL **: 12:34:56.789:
_gtk_css_provider_load_named:
assertion '!g_str_equal (name, DEFAULT_THEME_NAME)' failed
It's repeated often along with lots of subsequent errors. GIMP's main window appears, but the "welcome" window is small, square, and empty. It does not respond to events so I can't close it. Selecting File -> New in the main window has another small, square, empty window appear, like the welcome one, so I can't enter the width, height, etc., to create an image.
I assume some change has happened in how the AppImage has been built so 3.0.4 is happy here, but 3.0.6 isn't. I'm running each from the same shell window on the same machine, etc., so the system around the AppImage is the same.
Searching found a similar problem with an AppImage for Dolphin which the developers fixed, although the problem wasn't what they first thought. Perhaps that's useful to those who understand how AppImages are built. https://github.com/pkgforge-dev/Dolphin-.../issues/20
Is anyone here running 3.0.4 and 3.0.6 AppImages from https://download.gimp.org/gimp/v3.0/linux/ ? Do you suffer the same, or do they work for you?
Any clues on how to sort this?
|
|
|
|