0

In the python google.appengine.api.images docs there are crop functions such as crop(left_x, top_y, right_x, bottom_y), which allow you to specify a bounding box for cropping using percentages.

In addition, same docs say that one can append e.g. '=s32' to the image url returned by get_serving_url() in order to resize the image to 32px in the larger dimension. There are also crop options, however none of them are given with a bounding box (i.e. crop that's not defined from the corner nor around the center of the image) nor with percentages (all examples are around pixels).

Is there a way to replicate crop()'s behavior by appending options to the serving url returned by the get_serving_url() function?

scf
  • 396
  • 2
  • 19
  • [`crop()`](https://cloud.google.com/appengine/docs/standard/python/refdocs/modules/google/appengine/api/images#Image.crop) and [`get_serving_url`](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/6f5f3bcb81779679a24e0964a6c57c0c7deabfac/appengine/standard/images/api/blobstore.py) are slightly two different things. I know what you mean, though. Since one of the parameters of `get_serving_url()` is `size`, you could replicate the same behavior, if you calculated the size for the bounding box that will crop the image beforehand and passed it in the `size` parameter. – sllopis Nov 13 '19 at 10:41
  • @sllopis sorry if my question is not clear, but the url returned from get_serving_url can be appended with e.g. '=s32' to get an image of size 32 pixels in larger dimension. There are other options as well, however I can't find whether one could use these options to replicate the behavior of that crop() function in both aspects: 1. defined by a bounding box (so crop is not from corner nor center of image) 2. defined by percentages (rather than pixels). I'll edit the question a little to reflect that. – scf Nov 13 '19 at 10:59
  • I am not sure if I understand correctly what are you trying to do, but as specified [here](https://cloud.google.com/appengine/docs/standard/python/refdocs/google.appengine.api.images#google.appengine.api.images.get_serving_url), you can specify "crop" parameter as true, and it will request a cropped image. – ericcco Nov 19 '19 at 12:28

1 Answers1

0

According to Google's support, unfortunately it is not possible to crop a bounding box via serving_url as stated here .

Another point to consider is that their documentation of serving_url only support size and crop parameters only, but it works with a lot more options, so there is a possibility that it works as well, just be in mind that officially not.

And please, if you success on that, don't forget to share it here!

Fernando Oléa
  • 261
  • 3
  • 3