Skip to content

Expose structs: libraw_imgother_t and libraw_lensinfo_t#289

Open
pam-param-pam wants to merge 6 commits intoletmaik:mainfrom
pam-param-pam:main
Open

Expose structs: libraw_imgother_t and libraw_lensinfo_t#289
pam-param-pam wants to merge 6 commits intoletmaik:mainfrom
pam-param-pam:main

Conversation

@pam-param-pam
Copy link
Copy Markdown

Per what i said in #287
I exposed imgother_t and lensinfo_t structs.

Its my first real PR to an open source project. And I have no expierience with c++ pyhon wrappers so i apologize if I did something wrong.

Im unsure whetever i should add tests for this.
And im unsure if i should update the docs/add examples.

Im looking forward to hear what i should change/update

Copy link
Copy Markdown
Owner

@letmaik letmaik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, I think this is quite useful, especially if other libraries don't cover it. It definitely needs some tests, and I would change it to typed named tuples. Bonus points if you can extend the sphinx API docs as well.

Comment thread rawpy/_rawpy.pyx Outdated
Comment on lines +848 to +857
return {
"min_focal": l.MinFocal,
"max_focal": l.MaxFocal,
"max_ap_min_focal": l.MaxAp4MinFocal,
"max_ap_max_focal": l.MaxAp4MaxFocal,
"lens_make": l.LensMake.decode('utf-8', 'ignore'),
"lens": l.Lens.decode('utf-8', 'ignore'),
"focal_35mm": l.FocalLengthIn35mmFormat,
"exif_max_ap": l.EXIF_MaxAp,
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which of those fields do you need yourself? If the goal is lens correction, then probably only the make and the name. I would start small and only expose what people actually need for now.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed uneeded fields. I left maker, model, min and max focal

Comment thread rawpy/_rawpy.pyx Outdated
"shutter": o.shutter,
"aperture": o.aperture,
"focal_len": o.focal_len,
"timestamp": o.timestamp,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What data type is this? Does it need to be converted to a python datatime?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I converted it into a python datetime. Idk if the timezones are correct

Comment thread rawpy/_rawpy.pyx Outdated
Comment thread rawpy/_rawpy.pyx Outdated
"iso_speed": o.iso_speed,
"shutter": o.shutter,
"aperture": o.aperture,
"focal_len": o.focal_len,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this to focal_length?

Comment thread rawpy/_rawpy.pyx Outdated

return {
"iso_speed": o.iso_speed,
"shutter": o.shutter,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this to shutter_speed.

Comment thread rawpy/_rawpy.pyx Outdated
"max_focal": l.MaxFocal,
"max_ap_min_focal": l.MaxAp4MinFocal,
"max_ap_max_focal": l.MaxAp4MaxFocal,
"lens_make": l.LensMake.decode('utf-8', 'ignore'),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to maker?

Copy link
Copy Markdown
Contributor

@kmilos kmilos Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nit: this is "make" in the Exif spec (and as such in exiftool, exiv2, etc.)

For the camera body it is already "make" in libraw_iparams_t...

Comment thread rawpy/_rawpy.pyx Outdated
"max_ap_min_focal": l.MaxAp4MinFocal,
"max_ap_max_focal": l.MaxAp4MaxFocal,
"lens_make": l.LensMake.decode('utf-8', 'ignore'),
"lens": l.Lens.decode('utf-8', 'ignore'),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to model?

Comment thread rawpy/_rawpy.pyx Outdated
self.ensure_unpack()
cdef libraw_lensinfo_t *l = &self.p.imgdata.lens

return {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to expose this as named tuples like for the sizes property. Ideally typed like here: https://typing.python.org/en/latest/spec/namedtuples.html

@pam-param-pam
Copy link
Copy Markdown
Author

pam-param-pam commented Apr 12, 2026

I renamed fields.
Changed from dicts -> NamedTuples.
Removed unneeded fields
Extended docs
Extended basic_proccess example

I also added 2 tests. But im unsure if they are correct. I don't really see the point of veryfing each field since its either fully correct or not. And even if there was a bug it would be due to libraw and not due to the rawpy

shutter_speed is not really human readable. Its 0.05000000074505806 instead of 1/250. Unsure if u want the wrapper to convert it.

I would also like to expose gpsdata from other_t but it would need to be converted into something like this:

class GPS(NamedTuple):
    latitude: float
    longitude: float
    altitude: float | None
    altitude_ref: int
    timestamp: str | None

And idk if u want the the wrapper to handle the conversion(and if yes, in .pyx or in .pyi)

@pam-param-pam
Copy link
Copy Markdown
Author

Any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants