fix: xcf_stack GIMP 3 headless script execution
Use gimp-console when available, GIMP 3 Script-Fu API, and temp .scm batch files so layer stacking works without a display. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+5
-18
@@ -12,26 +12,10 @@ from imagepipeline.modules.xcf_stack import XcfStackModule
|
||||
from imagepipeline.utils.files import find_image_by_stem
|
||||
from tests.conftest import make_png
|
||||
|
||||
has_gimp = bool(shutil.which("gimp"))
|
||||
has_gimp = bool(shutil.which("gimp-console") or shutil.which("gimp"))
|
||||
has_magick = bool(shutil.which("magick") or shutil.which("convert"))
|
||||
|
||||
|
||||
def _gimp_headless_works() -> bool:
|
||||
gimp = shutil.which("gimp")
|
||||
if not gimp:
|
||||
return False
|
||||
try:
|
||||
from imagepipeline.utils.subprocess import run_command
|
||||
|
||||
run_command([gimp, "-idf", "-b", "(gimp-quit 0)"], timeout=10)
|
||||
return True
|
||||
except RuntimeError:
|
||||
return False
|
||||
|
||||
|
||||
has_working_gimp = _gimp_headless_works()
|
||||
|
||||
|
||||
class TestFindImageByStem:
|
||||
def test_finds_matching_stem_case_insensitively(self, tmp_path: Path) -> None:
|
||||
make_png(tmp_path / "Photo.PNG")
|
||||
@@ -174,7 +158,7 @@ class TestXcfStackRun:
|
||||
mock_stack.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.skipif(not has_working_gimp, reason="GIMP headless not available")
|
||||
@pytest.mark.skipif(not has_gimp, reason="GIMP not installed")
|
||||
@pytest.mark.skipif(not has_magick, reason="ImageMagick not installed")
|
||||
class TestStackImagesToXcfIntegration:
|
||||
def test_stacks_pngs_into_xcf(self, tmp_path: Path) -> None:
|
||||
@@ -198,3 +182,6 @@ class TestStackImagesToXcfIntegration:
|
||||
|
||||
assert outfile.is_file()
|
||||
assert outfile.stat().st_size > 0
|
||||
names = outfile.read_bytes()
|
||||
assert b"bottom" in names
|
||||
assert b"top" in names
|
||||
|
||||
Reference in New Issue
Block a user