Gimp-Forum.net
Problem with file-tiff-save - 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)
+--- Thread: Problem with file-tiff-save (/Thread-Problem-with-file-tiff-save)



Problem with file-tiff-save - Eonwe - 02-08-2022

Hello Gimp-Users,

i have the problem that a tiff-file saved with a macro with file-tiff-save can't be opened anymore using file-tiff-load. The load fails with: "RuntimeError: Procedure 'file-tiff-load' returned no return values" 

The file can however be opened using the Gimp-Ui.

I can recreate this behavior by saving a tiff from the UI with having the checkbox for "Layers" marked.
file-tiff-save has no parameters to modify this.

Do you now what the exact issue is and how can I fix this?

Thanks in advance!


RE: Problem with file-tiff-save - rich2005 - 02-08-2022

Which version of Gimp are you using ?  If the version is before Gimp 2.10.30 then it might be the embedded thumbnail causing the problem. It is a Windows problem.

Try opening the tiff image, then export with embedded thumbnail option OFF.

[attachment=7441]

If that is the problem recommend updating Gimp.

Edit: If you export the tiff without All layers checked then that is equivalent to flattening the image. Just single layer, same as a png or jpeg.


RE: Problem with file-tiff-save - Eonwe - 02-08-2022

Hi Rich, 

I know how to get a working tif out of gimp by hand, but I want to do it with a script, because I have hundreds of files that all require the same actions.
I was using 2.10.28 and switched to 2.10.30 now, but the result is nearly the same. My tiny-scheme gives me a .tif file, that can't be processed any further with additional scripts while modifying it with the UI is no problem.

And it seems that other automated processes that follow afterwards fail as well, while other tif-Files are no problem whatsoever.

What is the difference between file-tiff-save in scripts and the export command that the UI uses?
I wanted to upload an example file, but the forum won't let me due to size restrictions.


RE: Problem with file-tiff-save - rich2005 - 02-08-2022

Quote:What is the difference between file-tiff-save in scripts and the export command that the UI uses?

I do not know, maybe Ofnuts or Kevin can answer that one.

Quote:.. I want to do it with a script, because I have hundreds of files that all require the same actions.

Ok. I can reproduce the problem using the batch plugin BIMP. Tiff files exported with layers do not convert because they do not load. The same error message that you get Calling error for procedure 'gimp-file-load': Procedure 'file-tiff-load' returned no return values Just end up with zero size files.

Quote:And it seems that other automated processes that follow afterwards fail as well,

The tiff does not load so does not process.

--not Gimp --

Using ImageMagick mogrify I can get this warning from a Gimp multi-layer tiff

Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software. `OJPEGSetupDecode' @ warning/tiff.c/TIFFWarnings/949

That is the same for all gimp methods of tiff compression, must be the layers.

However it will process those problem multi-layer tiffs - flatten and convert a whole folder of tiff's Maybe that as a last resort.


RE: Problem with file-tiff-save - Eonwe - 02-09-2022

thanks rich, I can fix the images with imagemagick.

Is this a bug in the Gimp tiff export that needs to be fixed?


RE: Problem with file-tiff-save - rich2005 - 02-09-2022

(02-09-2022, 11:52 AM)Eonwe Wrote: thanks rich, I can fix the images with imagemagick.

Is this a bug in the Gimp tiff export that needs to be fixed?

Obviously something wrong. It is how to explain the problem to the Gimp developers. They do not go out of their way when a script is concerned.


RE: Problem with file-tiff-save - Ofnuts - 02-09-2022

(02-08-2022, 12:39 PM)Eonwe Wrote: Hello Gimp-Users,

i have the problem that a tiff-file saved with a macro with file-tiff-save can't be opened anymore using file-tiff-load. The load fails with: "RuntimeError: Procedure 'file-tiff-load' returned no return values" 

The file can however be opened using the Gimp-Ui.

I can recreate this behavior by saving a tiff from the UI with having the checkbox for "Layers" marked.
file-tiff-save has no parameters to modify this.

Do you now what the exact issue is and how can I fix this?

Thanks in advance!

Did you try to use plain file-load instead of file-tiff-load? Otherwise, can you show the save & load pieces of code?


RE: Problem with file-tiff-save - Eonwe - 02-10-2022

the command in my code is actually
Code:
file-load
gimp obviously passes that to
Code:
file-tiff-load

when a tiff is recognized.
I use this tiny-scheme to convert open jpg ,work some magic on it (adding the outline as path, removing unecessary space and changing the color profil) and then saving it as tiff. The brackets might not match because i snipped the code.
Code:
(define (jpg-to-tiff pattern)
(let* (
    (filelist (cadr (file-glob pattern 1)))
    )
    (while (not (null? filelist))

        (let* (
            (theFilenameIn (car filelist))
            (theImage (car (gimp-file-load RUN-NONINTERACTIVE theFilenameIn "")))
            (theDrawable (car (gimp-image-get-active-drawable theImage)))
            (theColor1 (car (gimp-image-pick-color theImage theDrawable 200 1 FALSE FALSE 0)))
            (theColor2 (car (gimp-image-pick-color theImage theDrawable 1 1 FALSE FALSE 0)))
            (theXresolution (- (car (gimp-image-get-resolution theImage)) 1))
            (test (unbreakupstr (reverse (cdr (reverse (strbreakup theFilenameIn ".")))) "."))
            (theFilenameOut (string-append test ".tif"))
            )

.
.
.

                    (theDrawable2 (car (gimp-image-get-active-drawable theImage)))
                    (theLayer2 (car (gimp-image-get-active-layer theImage)))                            
                    )

                    (plug-in-autocrop 1 theImage theDrawable2)
                    (gimp-layer-flatten theLayer2)
                    (plug-in-icc-profile-apply RUN-NONINTERACTIVE theImage "eciRGB_v2.icc" COLOR-RENDERING-INTENT-PERCEPTUAL FALSE)
                    (file-tiff-save RUN-NONINTERACTIVE theImage theDrawable2 theFilenameOut theFilenameOut 1)

                    (gimp-image-delete theImage)
                    (set! filelist (cdr filelist))
                )
            )
        )
    )
)
)

these files should then be uploaded to an external hosted file server, that renders various formats and a thumbnail picture. But this conversion fails. 
I have a second script that checks the files for certain technical details and sorts them into folders, this time in python (I got tired of the brackets):
Code:
def bilder_check(file_name):

   print(file_name)

   image = pdb.gimp_file_load(file_name, file_name)
   drawable = pdb.gimp_image_get_active_layer(image)
   has_alpha = pdb.gimp_drawable_has_alpha(drawable)
   width = pdb.gimp_image_width(image)
   height = pdb.gimp_image_height(image)
   xresolution, yresolution = pdb.gimp_image_get_resolution(image)
   num_vectors, vector_ids = pdb.gimp_image_get_vectors(image)
   vectors = pdb.gimp_image_get_vectors_by_name(image, "Freisteller")
   num_strokes, stroke_ids = pdb.gimp_vectors_get_strokes(vectors)
.
.
.
This one fails with the above mentioned error message on files that got processed by the first script. It works well with any other file.
I could recover the files with imagemagick mogrify. It could process the images but throwed some warnings as mentioned by rich.
The exact same behavior occurs when saving a tiff from the UI with "layers" checked.


RE: Problem with file-tiff-save - Ofnuts - 02-10-2022

Did you try without setting the color profile?


RE: Problem with file-tiff-save - rich2005 - 02-10-2022

Dear Ofnuts Wink I was going to put up a bug report, This using BIMP as the batch process. A 3 layer image, exported as a multi-layer tiff with all other options OFF. The same image / settings but with different compression formats (just in case)

[attachment=7443]

I can guess the response from the devs. External plugin, contact the maintainer for a fix.

Edit: A few more tests and it does seem to be a Gimp 2.10.30 issue (certainly not a 13 year old bug)
I can convert (tiff to flattened tiff or tiff to jpeg) those files using Gimp 2.10.22 using BIMP and get no errors.

FWIW I posted a bug report : https://gitlab.gnome.org/GNOME/gimp/-/issues/7852

--- off topic, but I think you have a comment in the bug thread. From the dev notes update ---
Stroking a path with source tools (Clone, Heal…) is now possible
when the tool is active and a source was selected.
Technically it's more of a bug fix because the GUI existed as though
it was meant to work, but since the report has existed for more than
13 years and I'm not sure it has ever worked
-----