07-17-2023, 07:28 AM
This script - full disclosure, I made it with the help of AI as I'm not much of a coder - is getting the following error:
batch command experienced an execution error:
Error: /: argument 1 must be: number
gimp: GEGL-WARNING: (../gegl/buffer/gegl-tile-handler-cache.c:1076):gegl_tile_cache_destroy: runtime check failed: (g_queue_is_empty (&cache_queue))
EEEEeEeek! 2 GeglBuffers leaked
I haven't been able to figure out how to fix it. I've tried the usual things--making sure GIMP is up to date, etc.
Thanks for any help offered.
batch command experienced an execution error:
Error: /: argument 1 must be: number
gimp: GEGL-WARNING: (../gegl/buffer/gegl-tile-handler-cache.c:1076):gegl_tile_cache_destroy: runtime check failed: (g_queue_is_empty (&cache_queue))
EEEEeEeek! 2 GeglBuffers leaked
I haven't been able to figure out how to fix it. I've tried the usual things--making sure GIMP is up to date, etc.
Thanks for any help offered.
Code:
#!/bin/bash
# Prompt for image selection
input_image=$(zenity --file-selection --title="Select an image or document" --file-filter="Image files | *.jpg *.jpeg *.png *.tiff *.webm *.pdf")
# Check if a file was selected or the dialog was canceled
if [ -z "$input_image" ]; then
echo "No file selected. Exiting."
exit 0
fi
# Extract the directory path from the input file
input_dir=$(dirname "$input_image")
# Extract the filename from the full path
filename=$(basename "$input_image")
# Construct the output image path in the same directory as the input file
output_image="${input_dir}/${filename}.jpg"
# Step 1: Scale the image to a width of 800px
# Step 2: Fit canvas to image size
# Step 3: Export to JPG with quality set to 80
gimp -i -b "(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE \"$input_image\" \"$input_image\")))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-image-scale image 800 (/ (gimp-image-width image) (gimp-image-height image)))
(gimp-image-resize-to-layers image)
(file-jpeg-save RUN-NONINTERACTIVE image drawable \"$output_image\" \"$output_image\" 0.8 0 1 1 \"\" \"\")
(gimp-image-delete image))" -b "(gimp-quit 0)"