Fixed
Status Update
Comments
[Deleted User] <[Deleted User]> #2
Upon further investigation, we actually needed to clarify the feature request. The existing media item endpoint DOES already preserve the aspect ratio - it shrinks the image to fit inside the bounding box created by the request for square dimensions. As a ScaleType, this would be a CENTER_INSIDE. The feature we're actually trying to request is a CENTER_CROP type scaling, where instead of scaling the entire image down so that it fits inside a bounding box (with blank space in the excess dimension), the image would be scaled down to equal or larger than the bounding box dimensions (so that the box is completely filled with the image, and any excess is cropped out). Apologies for the misleading title, which is incorrect since aspect ratio is always preserved.
[Deleted User] <[Deleted User]> #3
To give an example, let's say our media item is originally a 512x256 image. When we request the baseUrl with a "=w256-h256" suffix, we receive an image with 256x128 dimensions. Our feature request is to be able to get back a 256x256 image with preserved aspect ratio (even if the image is cropped in the excess dimension).
jf...@google.com <jf...@google.com> #4
Thanks for filing this feature request and describing your use case.
Center/crop scaling does sound like a good idea - I have forwarded this to the team. (There are quite a few complexities with cropping media - ie. which area should be cropped or preserved?)
Center/crop scaling does sound like a good idea - I have forwarded this to the team. (There are quite a few complexities with cropping media - ie. which area should be cropped or preserved?)
jf...@google.com <jf...@google.com> #5
(FWIW, for now you can do the cropping locally by requesting an image with larger dimensions based on its height/width ratio, with the smallest dimension set to the size you need.)
jf...@google.com <jf...@google.com> #6
I have updated the title, please let me know if that doesn't quite capture the intent.
jf...@google.com <jf...@google.com> #7
Good news - it is now possible to crop an image base URL to exact dimensions.
The documentation has been updated here:https://developers.google.com/photos/library/guides/access-media-items
The parameter "-c" crops the image to the dimensions you have set with "-w" and "-h". For example, you can set "=w256-h256-c" to get an image that is exactly 256x256px big.
The documentation has been updated here:
The parameter "-c" crops the image to the dimensions you have set with "-w" and "-h". For example, you can set "=w256-h256-c" to get an image that is exactly 256x256px big.
[Deleted User] <[Deleted User]> #8
Amazing! Nice work, thanks.
Description
The "Access media items" section of the API guide instructs us to "specify the dimensions that your application plans to display (so that the image can be scaled appropriately)" when accessing the baseUrl of a media item. In the case of an image that's originally wider than its height, the image will appear squished if we request square dimensions.
What is the purpose of this new feature?
Our Wear OS complication provider is attempting to allow a user to select an image from their Google Photos library and set it as the background of a watch face. Given that most Wear devices have round faces, the image would preferably target equal values for width and height (i.e. a square shape). The current request to a media item's baseUrl would stretch a widescreen image to make it fit inside the requested square dimensions. This image would look better if it was scaled and then cropped to the requested square.
Please provide any additional information below.
We could just download the full resolution image and then do the scaling and cropping locally with code, but then we wouldn't really be following the aforementioned instructions to "specify the dimensions that your application plans to display." We're perhaps imagining optional parameters akin to Android's ImageView.ScaleType (