forked from darktable-org/darktable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlightroom.c
More file actions
1371 lines (1195 loc) · 38.9 KB
/
Copy pathlightroom.c
File metadata and controls
1371 lines (1195 loc) · 38.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
This file is part of darktable,
copyright (c) 2009--2011 johannes hanika.
copyright (c) 2011--2012 henrik andersson.
darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
darktable is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with darktable. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/darktable.h"
#include "common/colorspaces.h"
#include "common/tags.h"
#include "common/curve_tools.h"
#include "common/ratings.h"
#include "common/colorlabels.h"
#include "common/debug.h"
#include "develop/lightroom.h"
#include "control/control.h"
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <sys/stat.h>
#include <string.h>
#include <ctype.h>
// copy here the iop params struct with the actual version. This is so to
// be as independant as possible of any iop evolutions. Indeed, we create
// the iop params into the database for a specific version. We then ask
// for a reload of the history parameter. If the iop has evolved since then
// the legacy circuitry will be called to convert the parameters.
//
// to add a new iop:
// 1. copy the struct
// 2. add LRDT_<iop_name>_VERSION with corresponding module version
// 3. use this version to pass in dt_add_hist()
#define LRDT_CLIPPING_VERSION 4
typedef struct dt_iop_clipping_params_t
{
float angle, cx, cy, cw, ch, k_h, k_v;
float kxa, kya, kxb, kyb, kxc, kyc, kxd, kyd;
int k_type, k_sym;
int k_apply, crop_auto;
}
dt_iop_clipping_params_t;
#define LRDT_EXPOSURE_VERSION 2
typedef struct dt_iop_exposure_params_t
{
float black, exposure, gain;
}
dt_iop_exposure_params_t;
#define LRDT_GRAIN_VERSION 1
typedef enum _dt_iop_grain_channel_t
{
DT_GRAIN_CHANNEL_HUE=0,
DT_GRAIN_CHANNEL_SATURATION,
DT_GRAIN_CHANNEL_LIGHTNESS,
DT_GRAIN_CHANNEL_RGB
}
_dt_iop_grain_channel_t;
typedef struct dt_iop_grain_params_t
{
_dt_iop_grain_channel_t channel;
float scale;
float strength;
}
dt_iop_grain_params_t;
typedef enum dt_iop_dither_t
{
DITHER_OFF = 0,
DITHER_8BIT = 1,
DITHER_16BIT = 2
} dt_iop_dither_t;
typedef struct dt_iop_fvector_2d_t
{
float x;
float y;
} dt_iop_vector_2d_t;
#define LRDT_VIGNETTE_VERSION 3
typedef struct dt_iop_vignette_params_t
{
float scale; // 0 - 100 Inner radius, percent of largest image dimension
float falloff_scale; // 0 - 100 Radius for falloff -- outer radius = inner radius + falloff_scale
float brightness; // -1 - 1 Strength of brightness reduction
float saturation; // -1 - 1 Strength of saturation reduction
dt_iop_vector_2d_t center; // Center of vignette
gboolean autoratio; //
float whratio; // 0-1 = width/height ratio, 1-2 = height/width ratio + 1
float shape;
int dithering; // if and how to perform dithering
}
dt_iop_vignette_params_t;
#define LRDT_SPOTS_VERSION 1
#define MAX_SPOTS 32
typedef struct spot_t
{
// position of the spot
float x, y;
// position to clone from
float xc, yc;
float radius;
}
spot_t;
typedef struct dt_iop_spots_params_t
{
int num_spots;
spot_t spot[MAX_SPOTS];
}
dt_iop_spots_params_t;
#define LRDT_TONECURVE_VERSION 3
#define DT_IOP_TONECURVE_MAXNODES 20
typedef enum tonecurve_channel_t
{
ch_L = 0,
ch_a = 1,
ch_b = 2,
ch_max = 3
}
tonecurve_channel_t;
typedef struct dt_iop_tonecurve_node_t
{
float x;
float y;
}
dt_iop_tonecurve_node_t;
typedef struct dt_iop_tonecurve_params_t
{
dt_iop_tonecurve_node_t tonecurve[3][DT_IOP_TONECURVE_MAXNODES]; // three curves (L, a, b) with max number of nodes
int tonecurve_nodes[3];
int tonecurve_type[3];
int tonecurve_autoscale_ab;
int tonecurve_preset;
}
dt_iop_tonecurve_params_t;
#define LRDT_COLORZONES_VERSION 2
#define DT_IOP_COLORZONES_BANDS 8
typedef enum dt_iop_colorzones_channel_t
{
DT_IOP_COLORZONES_L = 0,
DT_IOP_COLORZONES_C = 1,
DT_IOP_COLORZONES_h = 2
}
dt_iop_colorzones_channel_t;
typedef struct dt_iop_colorzones_params_t
{
int32_t channel;
float equalizer_x[3][DT_IOP_COLORZONES_BANDS], equalizer_y[3][DT_IOP_COLORZONES_BANDS];
}
dt_iop_colorzones_params_t;
#define LRDT_SPLITTONING_VERSION 1
typedef struct dt_iop_splittoning_params_t
{
float shadow_hue;
float shadow_saturation;
float highlight_hue;
float highlight_saturation;
float balance; // center luminance of gradient
float compress; // Compress range
}
dt_iop_splittoning_params_t;
#define LRDT_BILAT_VERSION 1
typedef struct dt_iop_bilat_params_t
{
float sigma_r;
float sigma_s;
float detail;
}
dt_iop_bilat_params_t;
#define LRDT_COLORIN_VERSION 1
#define DT_IOP_COLOR_ICC_LEN 100
typedef enum dt_iop_color_intent_t
{
DT_INTENT_PERCEPTUAL = INTENT_PERCEPTUAL, // 0
DT_INTENT_RELATIVE_COLORIMETRIC = INTENT_RELATIVE_COLORIMETRIC, // 1
DT_INTENT_SATURATION = INTENT_SATURATION, // 2
DT_INTENT_ABSOLUTE_COLORIMETRIC = INTENT_ABSOLUTE_COLORIMETRIC // 3
}
dt_iop_color_intent_t;
typedef struct dt_iop_colorin_params_t
{
char iccprofile[DT_IOP_COLOR_ICC_LEN];
dt_iop_color_intent_t intent;
}
dt_iop_colorin_params_t;
//
// end of iop structs
//
// the blend params for Lr import, not used in this mode (mode=0), as for iop generate the blend params for the
// version specified above.
#define LRDT_BLEND_VERSION 4
#define DEVELOP_BLENDIF_SIZE 16
typedef struct dt_develop_blend_params_t
{
/** blending mode */
uint32_t mode;
/** mixing opacity */
float opacity;
/** id of mask in current pipeline */
uint32_t mask_id;
/** blendif mask */
uint32_t blendif;
/** blur radius */
float radius;
/** blendif parameters */
float blendif_parameters[4*DEVELOP_BLENDIF_SIZE];
}
dt_develop_blend_params_t;
//
// end of blend_params
//
typedef struct lr2dt
{
float lr, dt;
} lr2dt_t;
char *dt_get_lightroom_xmp(int imgid)
{
char pathname[DT_MAX_FILENAME_LEN];
struct stat buf;
// Get full pathname
dt_image_full_path (imgid, pathname, DT_MAX_FILENAME_LEN);
// Look for extension
char *pos = strrchr(pathname, '.');
if (pos==NULL) { return NULL; }
// If found, replace extension with xmp
strncpy(pos+1, "xmp", 4);
if (!stat(pathname, &buf))
return g_strdup(pathname);
else
return NULL;
}
static float get_interpolate (lr2dt_t lr2dt_table[], float value)
{
int k=0;
while (lr2dt_table[k+1].lr < value) k++;
return lr2dt_table[k].dt +
((value - lr2dt_table[k].lr)
/ (lr2dt_table[k+1].lr - lr2dt_table[k].lr))
* (lr2dt_table[k+1].dt - lr2dt_table[k].dt);
}
static float lr2dt_blacks(float value)
{
lr2dt_t lr2dt_blacks_table[] =
{{-100, 0.020}, {-50, 0.005}, {0, 0}, {50, -0.005}, {100, -0.010}};
return get_interpolate (lr2dt_blacks_table, value);
}
static float lr2dt_exposure(float value)
{
lr2dt_t lr2dt_exposure_table[] =
{{-5, -4.5}, {0, 0}, {5, 4.5}};
return get_interpolate (lr2dt_exposure_table, value);
}
static float lr2dt_vignette_gain(float value)
{
lr2dt_t lr2dt_vignette_table[] =
{{-100, -1}, {-50, -0.7}, {0, 0}, {50, 0.5}, {100, 1}};
return get_interpolate (lr2dt_vignette_table, value);
}
static float lr2dt_vignette_midpoint(float value)
{
lr2dt_t lr2dt_vignette_table[] =
{{0, 74}, {4, 75}, {25, 85}, {50, 100}, {100, 100}};
return get_interpolate (lr2dt_vignette_table, value);
}
static float lr2dt_grain_amount(float value)
{
lr2dt_t lr2dt_grain_table[] =
{{0, 0}, {25, 20}, {50, 40}, {100, 80}};
return get_interpolate (lr2dt_grain_table, value);
}
static float lr2dt_grain_frequency(float value)
{
lr2dt_t lr2dt_grain_table[] =
{{0, 100}, {50, 100}, {75, 400}, {100, 800}};
return get_interpolate (lr2dt_grain_table, value) / 53.3;
}
static float lr2dt_splittoning_balance(float value)
{
lr2dt_t lr2dt_splittoning_table[] =
{{-100, 100}, {0, 0}, {100, 0}};
return get_interpolate (lr2dt_splittoning_table, value);
}
static float lr2dt_clarity(float value)
{
lr2dt_t lr2dt_clarity_table[] =
{{-100, -.650}, {0, 0}, {100, .650}};
return get_interpolate (lr2dt_clarity_table, value);
}
static void dt_add_hist (int imgid, char *operation, dt_iop_params_t *params, int params_size, char *imported, int version, int *import_count)
{
int32_t num = 0;
dt_develop_blend_params_t blend_params;
memset(&blend_params, 0, sizeof(dt_develop_blend_params_t));
// get current num if any
sqlite3_stmt *stmt;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select count(num) from history where imgid = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
if(sqlite3_step(stmt) == SQLITE_ROW)
{
num = sqlite3_column_int(stmt, 0);
}
sqlite3_finalize(stmt);
// add new history info
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "insert into history (imgid, num, module, operation, op_params, enabled, blendop_params, blendop_version) values (?1, ?2, ?3, ?4, ?5, 1, ?6, ?7)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, num);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, version);
DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 4, operation, strlen(operation), SQLITE_TRANSIENT);
DT_DEBUG_SQLITE3_BIND_BLOB(stmt, 5, params, params_size, SQLITE_TRANSIENT);
DT_DEBUG_SQLITE3_BIND_BLOB(stmt, 6, &blend_params, sizeof(dt_develop_blend_params_t), SQLITE_TRANSIENT);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 7, LRDT_BLEND_VERSION);
sqlite3_step (stmt);
sqlite3_finalize (stmt);
if (imported[0]) strcat(imported, ", ");
strcat(imported, dt_iop_get_localized_name(operation));
(*import_count)++;
}
void dt_lightroom_import (int imgid, dt_develop_t *dev, gboolean iauto)
{
gboolean refresh_needed = FALSE;
char imported[256] = {0};
// Get full pathname
char *pathname = dt_get_lightroom_xmp(imgid);
if (!pathname)
{
if (!iauto) dt_control_log(_("cannot find lightroom xmp!"));
return;
}
// Load LR xmp
xmlDocPtr doc;
xmlNodePtr entryNode;
// Parse xml document
doc = xmlParseEntity(pathname);
if (doc == NULL)
{
g_free(pathname);
return;
}
// Enter first node, xmpmeta
entryNode = xmlDocGetRootElement(doc);
if (xmlStrcmp(entryNode->name, (const xmlChar *)"xmpmeta"))
{
if (!iauto) dt_control_log(_("`%s' not a lightroom xmp!"), pathname);
g_free(pathname);
return;
}
// Check that this is really a Lightroom document
xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
if (xpathCtx == NULL)
{
g_free(pathname);
xmlFreeDoc(doc);
return;
}
xmlXPathRegisterNs(xpathCtx, BAD_CAST "stEvt", BAD_CAST "http://ns.adobe.com/xap/1.0/sType/ResourceEvent#");
xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression((const xmlChar *)"//@stEvt:softwareAgent", xpathCtx);
if (xpathObj == NULL)
{
if (!iauto) dt_control_log(_("`%s' not a lightroom xmp!"), pathname);
xmlXPathFreeContext(xpathCtx);
g_free(pathname);
xmlFreeDoc(doc);
return;
}
xmlNodeSetPtr xnodes = xpathObj->nodesetval;
if (xnodes != NULL && xnodes->nodeNr > 0)
{
xmlNodePtr xnode = xnodes->nodeTab[0];
xmlChar *value = xmlNodeListGetString(doc, xnode->xmlChildrenNode, 1);
if (!strstr((char *)value,"Lightroom"))
{
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
xmlFreeDoc(doc);
xmlFree(value);
if (!iauto) dt_control_log(_("`%s' not a lightroom xmp!"), pathname);
g_free(pathname);
return;
}
xmlFree(value);
}
else
{
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
if (!iauto) dt_control_log(_("`%s' not a lightroom xmp!"), pathname);
g_free(pathname);
return;
}
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
// Go safely to Description node
if (entryNode)
entryNode = entryNode->xmlChildrenNode;
if (entryNode)
entryNode = entryNode->next;
if (entryNode)
entryNode = entryNode->xmlChildrenNode;
if (entryNode)
entryNode = entryNode->next;
if (!entryNode || xmlStrcmp(entryNode->name, (const xmlChar *)"Description"))
{
if (!iauto) dt_control_log(_("`%s' not a lightroom xmp!"), pathname);
g_free(pathname);
return;
}
g_free(pathname);
// Look for attributes in the Description
dt_iop_clipping_params_t pc;
memset(&pc, 0, sizeof(pc));
gboolean has_crop = FALSE;
gboolean has_flip = FALSE;
dt_iop_exposure_params_t pe;
memset(&pe, 0, sizeof(pe));
gboolean has_exposure = FALSE;
dt_iop_vignette_params_t pv;
memset(&pv, 0, sizeof(pv));
gboolean has_vignette = FALSE;
dt_iop_grain_params_t pg;
memset(&pg, 0, sizeof(pg));
gboolean has_grain = FALSE;
dt_iop_spots_params_t ps;
memset(&ps, 0, sizeof(ps));
gboolean has_spots = FALSE;
typedef enum lr_curve_kind_t
{
linear = 0,
medium_contrast = 1,
string_contrast = 2,
custom = 3
} lr_curve_kind_t;
#define MAX_PTS 20
dt_iop_tonecurve_params_t ptc;
memset(&ptc, 0, sizeof(ptc));
int ptc_value[4] = {0, 0, 0, 0};
float ptc_split[3] = {0.0, 0.0, 0.0};
lr_curve_kind_t curve_kind = linear;
int curve_pts[MAX_PTS][2];
int n_pts = 0;
dt_iop_colorzones_params_t pcz;
memset(&pcz, 0, sizeof(pcz));
gboolean has_colorzones = FALSE;
dt_iop_splittoning_params_t pst;
memset(&pst, 0, sizeof(pst));
gboolean has_splittoning = FALSE;
dt_iop_bilat_params_t pbl;
memset(&pbl, 0, sizeof(pbl));
gboolean has_bilat = FALSE;
gboolean has_tags = FALSE;
int rating = 0;
gboolean has_rating = FALSE;
gdouble lat = 0, lon = 0;
gboolean has_gps = FALSE;
int color = 0;
gboolean has_colorlabel = FALSE;
float fratio = 0; // factor ratio image
int flip = 0; // flip value
float crop_roundness = 0; // from lightroom
int n_import = 0; // number of iop imported
const float hfactor = 3.0 / 9.0; // hue factor adjustment (use 3 out of 9 boxes in colorzones)
const float lfactor = 4.0 / 9.0; // lightness factor adjustment (use 4 out of 9 boxes in colorzones)
int iwidth = 0, iheight = 0; // image width / height
int orientation = 1;
xmlAttr* attribute = entryNode->properties;
while(attribute && attribute->name && attribute->children)
{
xmlChar* value = xmlNodeListGetString(entryNode->doc, attribute->children, 1);
if (!xmlStrcmp(attribute->name, (const xmlChar *) "CropTop"))
pc.cy = atof((char *)value);
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "CropRight"))
pc.cw = atof((char *)value);
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "CropLeft"))
pc.cx = atof((char *)value);
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "CropBottom"))
pc.ch = atof((char *)value);
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "CropAngle"))
pc.angle = -atof((char *)value);
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ImageWidth"))
iwidth = atoi((char *)value);
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ImageLength"))
iheight = atoi((char *)value);
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "Orientation"))
{
orientation = atoi((char *)value);
if (orientation == 1 || orientation == 8) flip = 0;
else if (orientation == 2 || orientation == 7) flip = 1;
else if (orientation == 3 || orientation == 6) flip = 3;
else if (orientation == 4 || orientation == 5) flip = 2;
if (orientation != 1) has_flip = TRUE;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HasCrop"))
{
if (!xmlStrcmp(value, (const xmlChar *)"True"))
has_crop = TRUE;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "Blacks2012"))
{
int v = atoi((char *)value);
if (v != 0)
{
has_exposure = TRUE;
pe.black = lr2dt_blacks((float)v);
}
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "Exposure2012"))
{
float v = atof((char *)value);
if (v != 0.0)
{
has_exposure = TRUE;
pe.exposure = lr2dt_exposure(v);
}
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "PostCropVignetteAmount"))
{
int v = atoi((char *)value);
if (v != 0)
{
has_vignette = TRUE;
pv.brightness = lr2dt_vignette_gain((float)v);
}
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "PostCropVignetteMidpoint"))
{
int v = atoi((char *)value);
pv.scale = lr2dt_vignette_midpoint((float)v);
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "PostCropVignetteStyle"))
{
int v = atoi((char *)value);
if (v == 1) // Highlight Priority
pv.saturation = -0.300;
else // Color Priority & Paint Overlay
pv.saturation = -0.200;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "PostCropVignetteFeather"))
{
int v = atoi((char *)value);
if (v != 0)
pv.falloff_scale = (float)v;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "PostCropVignetteRoundness"))
{
int v = atoi((char *)value);
crop_roundness = (float)v;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "GrainAmount"))
{
int v = atoi((char *)value);
if (v != 0)
{
has_grain = TRUE;
pg.strength = lr2dt_grain_amount((float)v);
}
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "GrainFrequency"))
{
int v = atoi((char *)value);
if (v != 0)
pg.scale = lr2dt_grain_frequency((float)v);
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ParametricShadows"))
{
ptc_value[0] = atoi((char *)value);
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ParametricDarks"))
{
ptc_value[1] = atoi((char *)value);
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ParametricLights"))
{
ptc_value[2] = atoi((char *)value);
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ParametricHighlights"))
{
ptc_value[3] = atoi((char *)value);
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ParametricShadowSplit"))
{
ptc_split[0] = atof((char *)value) / 100.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ParametricMidtoneSplit"))
{
ptc_split[1] = atof((char *)value) / 100.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ParametricHighlightSplit"))
{
ptc_split[2] = atof((char *)value) / 100.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "ToneCurveName2012"))
{
if (!xmlStrcmp(value, (const xmlChar *)"Linear"))
curve_kind = linear;
else if (!xmlStrcmp(value, (const xmlChar *)"Medium Contrast"))
curve_kind = medium_contrast;
else if (!xmlStrcmp(value, (const xmlChar *)"Strong Contrast"))
curve_kind = medium_contrast;
else if (!xmlStrcmp(value, (const xmlChar *)"Custom"))
curve_kind = custom;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SaturationAdjustmentRed"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[1][0] = 0.5 + (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SaturationAdjustmentOrange"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[1][1] = 0.5 + (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SaturationAdjustmentYellow"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[1][2] = 0.5 + (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SaturationAdjustmentGreen"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[1][3] = 0.5 + (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SaturationAdjustmentAqua"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[1][4] = 0.5 + (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SaturationAdjustmentBlue"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[1][5] = 0.5 + (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SaturationAdjustmentPurple"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[1][6] = 0.5 + (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SaturationAdjustmentMagenta"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[1][7] = 0.5 + (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "LuminanceAdjustmentRed"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[0][0] = 0.5 + lfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "LuminanceAdjustmentOrange"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[0][1] = 0.5 + lfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "LuminanceAdjustmentYellow"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[0][2] = 0.5 + lfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "LuminanceAdjustmentGreen"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[0][3] = 0.5 + lfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "LuminanceAdjustmentAqua"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[0][4] = 0.5 + lfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "LuminanceAdjustmentBlue"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[0][5] = 0.5 + lfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "LuminanceAdjustmentPurple"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[0][6] = 0.5 + lfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "LuminanceAdjustmentMagenta"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[0][7] = 0.5 + lfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HueAdjustmentRed"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[2][0] = 0.5 + hfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HueAdjustmentOrange"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[2][1] = 0.5 + hfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HueAdjustmentYellow"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[2][2] = 0.5 + hfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HueAdjustmentGreen"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[2][3] = 0.5 + hfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HueAdjustmentAqua"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[2][4] = 0.5 + hfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HueAdjustmentBlue"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[2][5] = 0.5 + hfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HueAdjustmentPurple"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[2][6] = 0.5 + hfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "HueAdjustmentMagenta"))
{
int v = atoi((char *)value);
if (v!=0)
has_colorzones = TRUE;
pcz.equalizer_y[2][7] = 0.5 + hfactor * (float)v / 200.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SplitToningShawowHue"))
{
int v = atoi((char *)value);
if (v!=0)
has_splittoning = TRUE;
pst.shadow_hue = (float)v / 255.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SplitToningShawowSaturation"))
{
int v = atoi((char *)value);
if (v!=0)
has_splittoning = TRUE;
pst.shadow_saturation = (float)v / 100.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SplitToningHighlightHue"))
{
int v = atoi((char *)value);
if (v!=0)
has_splittoning = TRUE;
pst.highlight_hue = (float)v / 255.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SplitToningHighlightSaturation"))
{
int v = atoi((char *)value);
if (v!=0)
has_splittoning = TRUE;
pst.highlight_saturation = (float)v / 100.0;
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "SplitToningBalance"))
{
float v = atof((char *)value);
pst.balance = lr2dt_splittoning_balance(v);
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "Clarity2012"))
{
int v = atoi((char *)value);
if (v!=0)
{
has_bilat = TRUE;
pbl.detail = lr2dt_clarity((float)v);
}
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "Rating"))
{
int v = atoi((char *)value);
if (v!=0)
{
rating = v;
has_rating = TRUE;
}
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "GPSLatitude"))
{
int deg;
double msec;
char d;
if (sscanf((const char *)value, "%d,%lf%c", °, &msec, &d))
{
lat = deg + msec / 60.0;
if (d == 'S') lat = -lat;
has_gps = TRUE;
}
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "GPSLongitude"))
{
int deg;
double msec;
char d;
if (sscanf((const char *)value, "%d,%lf%c", °, &msec, &d))
{
lon = deg + msec / 60.0;
if (d == 'W') lon = -lon;
has_gps = TRUE;
}
}
else if (!xmlStrcmp(attribute->name, (const xmlChar *) "Label"))
{
for(int i=0; value[i]; i++)
value[i] = tolower(value[i]);
if (!strcmp((char *)value, _("red")))
color = 0;
else if (!strcmp((char *)value, _("yellow")))
color = 1;
else if (!strcmp((char *)value, _("green")))
color = 2;
else if (!strcmp((char *)value, _("blue")))
color = 3;
else
// just an else here to catch all other cases as on lightroom one can
// change the names of labels. So purple and the user's defined labels
// will be mapped to purple on darktable.
color = 4;
has_colorlabel = TRUE;
}
xmlFree(value);
attribute = attribute->next;
}
// Look for tags (subject/Bag/* and RetouchInfo/seq/*)
entryNode = entryNode->xmlChildrenNode;
if (entryNode) entryNode = entryNode->next;
while (entryNode)
{
if (dev == NULL && !xmlStrcmp(entryNode->name, (const xmlChar *) "subject"))
{
xmlNodePtr tagNode = entryNode;
tagNode = tagNode->xmlChildrenNode;
tagNode = tagNode->next;
tagNode = tagNode->xmlChildrenNode;
tagNode = tagNode->next;
while (tagNode)
{
if (!xmlStrcmp(tagNode->name, (const xmlChar *) "li"))