Capacitor Camera Plugin ignores targetWidth/targetHeight options

I have been using the Capacitor camera plugin to take photos in our mobile app for many years and it has been working well. Recently, the developers of the camera plugin deprecated the Camera.getPhoto method and replaced it with the new Camera.takePhoto method. Ok fine, but the the new takePhoto method just ignores the new targetWidth and targetHeight options.

My new code using the takePhoto method is very simple:

const imageResult: MediaResult = await Camera.takePhoto({
		quality: 80,
		editable: "no",
		includeMetadata: true,
		cameraDirection: CameraDirection.Rear,
		correctOrientation: true,
		targetWidth: 1024,
		targetHeight: 768
	})

From a native Android app, there are 2 ways to get the JPEG image data as a base-64 string. You can either access imageResult.thumbnail for a thumbnail of the image, or you can read the image file data using the path imageResult.uri. However, neither of these options result in an image that is 1024x768.

Directly accessing the image data from imageResult.thumbnail gives you a resolution of 576x768, which makes sense for a thumbnail.

Alternative, reading the file URI with the following code:

const fileResult: ReadFileResult = await Filesystem.readFile({ path: imageResult.uri })

And then getting the image data from fileResult.data gives you a resolution of 3456x4608, which is the phone camera’s maximum resolution.

What am I doing wrong? How can I get the new Camera.takePhoto method to honor the resolution of 1024x768 that I’m requesting?