8

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

Community
  • 1
  • 1
katie
  • 197
  • 2
  • 11
  • [Android does not have a `CROP` `Intent`](https://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html). There are [many image cropping libraries](http://android-arsenal.com/tag/45) available. Please use one. – CommonsWare May 27 '15 at 15:44
  • @CommonsWare I know. I'm not using this, but I just wondering, because tons of examples like this floating around on the internet. Thanks for point it out though. – katie May 27 '15 at 18:36

2 Answers2

6

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!

Miguelos
  • 304
  • 1
  • 4
  • 17
Jorge Cordero
  • 142
  • 2
  • 6
5

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.