crop: apply the aspect ratio dialed in on the camera - #22088
Conversation
|
On Fuji, from the earlier thread: I have opened Reading it through Exiv2 is not possible, the ratio is in the raf container That would also open the door for the other decoders, since the field is Worth flagging: I have no Fuji body, so that PR is explicitly marked For the record on the rest of the vendors, LibRaw parses this for Canon, Disclosure: written with AI assistance (Claude Code with Claude Opus 5). |
|
There should be enough images in Play Raw on pixl.us to test more vendors. I think there is also the images from raw.pilx.us |
29d686a to
4f95f32
Compare
|
Rebased onto current master and squashed to one commit, so the earlier Sony is out. @TurboGit, I added it when you asked and I have now removed Olympus is no longer untested. raw.pixls.us had suitable samples: Fujifilm is darktable-org/rawspeed#988, verified there against an X-T200 So of the four you asked about: Olympus and Canon work and are tested, Still open from my side is the question in the description about switching Disclosure: written with AI assistance (Claude Code with Claude Opus 5). |
|
As far as supporting cameras, I think we support the ones that have exiv2 tags and when the rest are supported by exiv2 then we add/enable them. I don't think we want to get into writing and supporting our own separate raw file metadata decoding. If someone wants to provide patches upstream to exiv2 that would be good. |
|
Agreed, and that is what this does - Canon and Olympus are read from Exiv2 On upstreaming: that is exactly where Sony went. Exiv2 misparses the camera Fuji is the one case I would like your read on. The value is in the raf Disclosure: written with AI assistance (Claude Code with Claude Opus 5). |
|
Does exiftool support Fuji aspect ratio? Maybe we support all the "odd" cameras with exiftool and a lua-script than runs on import and populates the field |
|
Yes - The precedent is there too: eleven of the bundled lua-scripts already call Two limits worth knowing before betting on it. The lua image API has So I would see it as a good optional add-on for cameras we cannot reach, Disclosure: written with AI assistance (Claude Code with Claude Opus 5). |
We could add the exif tags to metadata editor, which then makes them accessible to Lua, so Lua could populate the image field after getting the info from exiftool. Once the value is set, it's stored in the database and accessible to other modules. |
|
That works, and the machinery is already there - It also solves the objection I raised: because it lands in the database, the One thing worth deciding deliberately: it puts a camera fact into the Disclosure: written with AI assistance (Claude Code with Claude Opus 5). |
|
@hennikul Can you add to your |
|
@hennikul : We need a release notes entry for this. TIA. |
4f95f32 to
1b7abcd
Compare
Cameras that let you pick an aspect ratio in the viewfinder record that choice in the raw file without destroying the surrounding pixels. Other editors reproduce the framing on open and let you take it back; we showed the full sensor readout and dropped the intent on the floor. Read the ratio into the image and let the crop module center it on the sensor area, enabling itself so the framing is there right away while staying free to be moved around within the full frame. We deliberately keep the ratio alone instead of the box the camera reports. That box is centered on the output area of the camera, which is not quite the area we hand to the pipe, so reusing it would mean matching every vendor's idea of the full frame. Centering a ratio ourselves sidesteps that, and it is also the only thing some vendors record. The module stays off when the ratio it works out is the one it was handed anyway, so a vendor that applied the crop to the raw data after all, or a value read as something it is not, does nothing rather than cropping the image wrongly. Canon and Olympus are read for now, but the reader is a table of per-vendor functions and everything downstream is brand agnostic, so adding a vendor is one function and one line. Nikon needs nothing, it writes only the cropped area. Fuji and Sony are not reachable through Exiv2 and want doing in rawspeed instead. A DefaultUserCrop coming from the raw keeps its current behaviour of only preloading the parameters, untouched. Tested on an EOS R6 across 1:1, 4:3 and 16:9 in landscape and portrait with native 3:2 left alone, and on Olympus E-M10 Mark IV (16:9), E-P2 (3:2), TG-6 (3:2) and E-PL9 (native 4:3) samples from raw.pixls.us. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1b7abcd to
3e4ad0f
Compare
Reproduces the aspect ratio dialed in on the camera as a crop that is applied
on open but stays editable.
Addresses #22087, and picks up #19109 (closed as not planned) with the
brand-generic approach @kmilos asked for there.
Rebased onto current master and squashed into one commit. Sony has been
dropped since the first push, see below.
What it does
Cameras that let you pick an aspect ratio in the viewfinder record the choice
in the raw without destroying the surrounding pixels. We showed the full
sensor readout, so the framing chosen while shooting was lost. Now the crop
module centers that ratio on the sensor area and enables itself: the intended
framing is there on open, the aspect is locked to it in the combo box, and
the whole frame is still available to reframe within or to get back by
switching crop off.
Design notes
The ratio is kept, the vendor's box is not. @kmilos pointed out in #19109
that we do not apply the same full-sensor crop as the vendor. On an EOS R6
the camera reports its 1:1 crop as 3648x3648 at x=912 against its own
5472x3648 output area, while the pipe gets 5496x3670. Rather than track each
vendor's framing, only the ratio is taken and centered on the area we
actually produce. Users get marginally more image than the camera would have
given them.
Vendor readers are a table.
_check_camera_aspect()walks a list ofper-vendor functions; everything downstream is brand agnostic. Adding a
vendor is one function and one line.
Nothing happens rather than the wrong thing. The module stays off when
the ratio it works out is the one it was handed anyway, so a vendor that
applied the crop to the raw data after all, or a value read as something it
is not, does nothing rather than cropping the image wrongly.
DefaultUserCropis untouched. The DNG path keeps its current behaviourof only preloading the parameters.
default_enabledis set exclusively onthe camera-aspect path.
Portrait.
p_width/p_heightare still in sensor orientation atreload_defaults()time while crop runs after flip, so the box is swappedwhen the orientation swaps axes. The box is centered, which leaves the
mirroring bits a no-op.
Vendors
Canon.AspectInfo(0x9a), implemented and testedOlympusIp.AspectRatio(0x1112), implemented and testedOn Sony. I had added a reader in the first push and have removed it. It
cannot be made to work through Exiv2 and I could not verify it on anything.
On the only non-native A-mount sample available (DSLR-A580 from
raw.pixls.us) the ratio lives at
CameraSettings3byte 0x0a, and Exiv2parses that byte-oriented block as big endian shorts, so every
Sony2Csvalue is two unrelated bytes glued together and 0x0a is not exposed at all.
Filed as Exiv2/exiv2#9469. Newer bodies keep the setting in the undecoded
Tag2010. Rather than ship a reader that fires on a misparsed block, Sony isleft out; it wants the rawspeed route as Fujifilm did.
Testing
EOS R6 cRAW, and Olympus samples from raw.pixls.us, exported with
darktable-cli.Also confirmed in the GUI: crop shows enabled with the aspect locked, and
dragging reframes within the full sensor area.
The 1.85:1 entry in the Canon table is untested, no body I have offers it.
Two things worth raising
Switching a module on by default is a policy call rather than a detail, and
it is the part I would most like review on. @jenshannoschwalm noted in #19109
that the DNG path is deliberately off-but-available; I left that alone and
scoped this strictly to camera aspect settings, but I can put the new
behaviour behind a preference instead if that is preferred.
Separately, and not caused by this:
modify_roi_out()aligns width andheight independently to the ratio's factors when exporting, so the pair is
only exact when both land on the same multiple. The TG-6 3:2 above comes out
at 1.5011 for that reason, and a manually set ratio behaves the same way.
Happy to file it separately if you think it is worth fixing.
Disclosure: designed, written and tested with AI assistance (Claude Code with Claude Opus 5).
Verified against current master and builds clean with no new warnings.