Use GIMP color curve with ImageMagick

5

1

I created a color curve with GIMP. It looks like this:

~/.gimp2.8/curves/selphy

(Just the first lines)

# GIMP curves tool settings

(time 0)
(channel value)
(curve
    (curve-type smooth)
    (n-points 17)
    (points 34 0.000000 0.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 0.375000 0.490637 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 1.000000 1.000000)
    (n-samples 256)
    (samples 256 .....

I want to batch process some images with convert (ImageMagick).

Is there a way to use this curve with convert?

guettli

Posted 2013-12-19T20:41:44.957

Reputation: 347

To keep resolution, this works best: convert -density 300 -quality 100 $file -level 0%,100%,2.0 new/$file – lalebarde – 2015-01-10T09:00:55.610

1I found a solution to solve my initial problem. This convert call changes the brightness like my curve in gimp: mkdir -p new; for file in *JPG *jpg; do echo $(date) $file; convert $file -level 0%,100%,2.0 new/$file; done. But this question (apply gimp curve with convert) is still interesting for me. – guettli – 2013-12-22T14:48:16.067

Answers

1

If you don't mind using GIMP in batch mode instead of ImageMagick, you can use a Script-Fu script like this:

(define (color-curves filename output-filename curve)
  (let* (
      (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
      (drawable (car (gimp-image-get-active-layer image)))
    )
    (gimp-curves-explicit drawable 0 256 curve)
    (gimp-file-save RUN-NONINTERACTIVE image drawable output-filename output-filename)
  )
)

Save it as ~/.gimp-2.8/scripts/color-curves.scm.

Then, on the console:

gimp -i -b '(color-curves "intput.jpg" "output.jpg" #(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 6 6 6 6 6 7 7 7 7 8 8 8 9 9 9 9 10 10 10 11 11 11 12 12 13 13 13 14 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 25 25 26 27 27 28 28 29 30 31 31 32 33 33 34 35 36 37 37 38 39 40 41 42 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 61 62 64 66 67 69 71 73 76 78 80 83 85 88 90 93 96 98 101 104 107 110 113 116 119 122 125 128 132 135 138 141 144 148 151 154 157 160 163 167 170 173 176 179 182 185 188 191 194 197 199 202 205 207 210 212 215 217 219 222 224 226 228 228 230 231 233 235 236 237 239 240 241 242 243 244 245 246 247 248 249 249 250 250 251 251 252 252 252 253 253 253 254 254 254 254 254 254 255 255 255 255 255 255))' -b '(gimp-quit 0)'

where the third argument to color-curves are the values of samples in your color curve file multiplied by 255 and rounded. input.jpg and output.jpg are the input and output images (resp.).

peter

Posted 2013-12-19T20:41:44.957

Reputation: 111

0

i've once seen a script with the following method utilising imagemagick(1) .

  1. create a black canvas .
  2. draw a line using control points .
  3. paint the area below the line to white .
  4. resize the image into a 1-pixel-height bar and turn it clockwise .

this way, we get a gray gradient , feed it to imagemagick as lut aka. lookup table . apply this by colour channels .


besides , gimp comes with lisp functions gimp-curves-spline and gimp-curves-explicit , we can write some small programme and run with the batch redering engine . a curveloader package can parse the curve file format . refer to manuals if necessary .

把友情留在无盐

Posted 2013-12-19T20:41:44.957

Reputation: 383