Any way to get centercrop or centerfit type?
Cause of I will post the centercrop or centerfit params to server. And the server will make transform. For example The Nginx have crop service,you could post the image url like http://the/image/path/someimage.jpg!t400x400.jpg and will return a 400X400 and centerCrop image.
How could I get the centerCrop or centerFit type?
You have to roll your own because you can't know what transformations are applied to the request. What if it's CircleCrop and a WaterMark one after the other?
But don't worry it's kind of easy: https://github.com/bumptech/glide/wiki/Downloading-custom-sizes-with-Glide
You will need something like:
class MyDataModel {
String url;
ImageView.ScaleType scaleType;
String buildUrl(int width, int height) {
return this.url + transform(width, height);
}
String transform(int width, int height) {
return scaleType == ScaleType.CENTER_CROP?
String.format(Locale.ROOT, "!t%dx%d.%s", width, height, getExtension(url))
: // TODO modify to switch-case if there are more options
""
;
}
}
Here's how Glide maps ScaleType to default Transformations: https://github.com/bumptech/glide/blob/3.0/library/src/main/java/com/bumptech/glide/GenericRequestBuilder.java#L675
When you say "post", do you mean "send/request" or "HTTP POST"?
Thanks.