How to change the 'color temperature' in script-fu/scheme?

34 Views Asked by At

devs I'm working over a C# project and I execute gimp-console.exe to execute scripts and I put some paths (the input and the output image) as parameters to process some functions to this images.

Parallel.ForEach(Directory.GetFiles(scriptPath, "*.scm", SearchOption.AllDirectories), new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, scriptFile =>
                {
                    string script = Path.GetFileNameWithoutExtension(scriptFile);
                    string pathIMG_Output = Path.Combine(rutaSave, $"{Path.GetFileNameWithoutExtension(file)}{script}{DateTime.Now:dd-MM-yyyy-fff}.jpg");

                    ProcessStartInfo startInfo = new ProcessStartInfo
                    {
                        FileName = gimpPath,
                        Arguments = $"--no-data --no-fonts --no-interface --no-splash -i -b \"({script} \\\"{file}\\\" \\\"{pathIMG_Output}\\\")\" -b \"(gimp-quit 0)\"",
                        UseShellExecute = false,
                        RedirectStandardOutput = false,
                        CreateNoWindow = true,
                        RedirectStandardError = false
                    };

                    using (Process process = Process.Start(startInfo))
                    {

                        process.WaitForExit();

                        if (process.ExitCode == 0)
                        {

So I can change color balance, shadows and highlights and more functions but I can't change the color temperature values, is there a way o solution to work over this??. And adding this how can I do it faster because i already use parallel.foreach it still take so long to export images if it is 15 images or more?? it could be with c# or inside the scripts is there something to call/use gegl library quickly??

I already try color balance to modify the rgb color values but this doesn't export the same results if I put 6500.0 (6500 kelvin) in the 'Original temperature' and 5500.0 in 'Intended temperature' but I don't really know what values should be there to get the same results. I already check over chatgpt and I didn't receive better solutions.

Here I put an example of what I'm using as script and where color balance work exactly as Gimp

(define (script2_ file pathIMG_Output)
  (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE file file)))
         (drawable (car (gimp-image-get-active-layer image)))
         )
    (gimp-drawable-levels drawable 1 (/ 0.0 255.0) (/ 140.0 255.0) 0 1.0 (/ 0.0 255.0) (/ 255.0 255.0) 0)
    (gimp-drawable-levels drawable 3 0.0 1.0 0.0 1.0 0.0 1.0 0)
    (gimp-drawable-levels drawable 2 (/ 0.0 255.0) (/ 255.0 255.0) 0 1.0 (/ 0.0 255.0) (/ 255.0 255.0) 0)
    (file-jpeg-save 1 image drawable pathIMG_Output pathIMG_Output 0.9 0.0 0 0 "Saving JPEG image" 0 0 0 0)
    (gimp-image-delete image)
  )
)
this one works as prove it should be a way to do it where I just change brightness/contrast: 
(define (script1_ file pathIMG_Output)
  (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE file file)))
         (drawable (car (gimp-image-get-active-layer image)))
         )
    (gimp-brightness-contrast drawable -5 9)
    (file-jpeg-save 1 image drawable pathIMG_Output pathIMG_Output 0.9 0.0 0 0 "Saving JPEG image" 0 0 0 0)
    (gimp-image-delete image)
  )
)
0

There are 0 best solutions below