Skip to content

Commit b1a42a5

Browse files
committed
Support v4 profiles.
1 parent 7f73e87 commit b1a42a5

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

assets/raw-editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function loadSettings() {
3838
if (settings.process) form.process.value = settings.process.toFixed(1);
3939
if (settings.profiles) {
4040
let group = form.profile.lastElementChild;
41-
group.prepend(...settings.profiles.map(p => new Option(p.replace(/ v2$/, ''), p)));
41+
group.prepend(...settings.profiles.map(p => new Option(p.replace(/ v\d$/, ''), p)));
4242
}
4343
form.toneCurve.value = settings.toneCurve;
4444
form.lensProfile.checked = settings.lensProfile;

pkg/craw/profiles.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ func GetCameraProfiles(make, model string) ([]string, error) {
3434
var matches bool
3535
if test == "" || test == model || test == makeModel {
3636
matches = true
37-
} else if n := strings.IndexByte(test, ' '); n > 0 {
38-
testMake, testModel := test[:n], test[n+1:]
37+
} else if testMake, testModel, ok := strings.Cut(test, " "); ok {
3938
matches = testModel == model && strings.Contains(make, testMake)
4039
}
4140
if matches {

profiles.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,26 @@ func loadProfiles(make, model string, process float32, grayscale bool, profile,
109109
craw.EmbedProfiles = dngconv.Path
110110
profiles, _ := craw.GetCameraProfileNames(make, model)
111111

112-
res.adobe = "Adobe Standard"
112+
upgraded := map[string]string{}
113113
for _, name := range profiles {
114-
if slices.Contains(profiles, name+" v2") {
115-
// skip legacy
116-
continue
114+
key := name
115+
switch {
116+
case strings.HasSuffix(key, " v2"):
117+
key = name[:len(key)-len(" v2")]
118+
case strings.HasSuffix(key, " v4"):
119+
key = name[:len(key)-len(" v4")]
120+
}
121+
if upgraded[key] < name {
122+
upgraded[key] = name
117123
}
118-
if strings.HasPrefix(name, "Adobe Standard") {
124+
}
125+
126+
res.adobe = "Adobe Standard"
127+
for key, name := range upgraded {
128+
if key == "Adobe Standard" {
119129
res.adobe = name
120130
} else {
121-
res.other = append(res.other, string(name))
131+
res.other = append(res.other, name)
122132
}
123133
}
124134

0 commit comments

Comments
 (0)