I am no expert on the various image file formats to be sure the RAW format is uncompressd and larger and is essentially unprocessed in any substantive way. They are reputed to give the maximum ability to post process and edit image information. For stacking and background subtraction. When converted to JPG the processing and compression reduces information in exchange for smaller size = Los of information. This is a synopsis of the various formats: https://digital-photography-school.com/understanding-all-the-different-image-file-formats/
Additionally, there is the concept of binning pixels that effectively reduces resolution but sums several adjacent pixels into one sum.
The astropicam program I referred to earlier incorporates this concept. I believe it is an inherent capability of the camera chip, if I recall correctly. Again, I am very new to dabbling and not proficient, to say the least. There may be something to learn from that application; it is based on the older camera routines rather than the libcamera one in more recent releases.