Home » Android » Android – What is outputX/outputY and aspectX/aspectY when crop an image from gallery or camera?

Android – What is outputX/outputY and aspectX/aspectY when crop an image from gallery or camera?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I read a lot of posts about cropping an image from gallery or camera, and I know outputX/outputY refers to the size of the output/cropped image. However, nobody ever explained what does aspectX/aspectY do? And what is the unit of outputX/outputY? Is it dp?

Sample code: Modify Android crop intent

How to&Answers:

aspectX and aspectY are the ratio of width and height of the result image, if you need to scale it. width / height = aspectX / aspectY

And I don’t think the unit of outputX and outputY are dp. I think its just pixel.

Answer:

aspectX and aspectY are just a proportion, so if you want an 16:9 image putting aspectX = 16 and aspectY = 9 you get the desired ratio.

Good Luck!