Cloud Storage 存储桶必须使用精细的访问控制列表,以确保 Images API 正常工作。对于已配置为使用统一存储桶级访问权限的存储桶,Images API 将无法提取该存储桶中的图片并会抛出 TransformationError 错误消息。如果您的存储桶正是以这种方式进行配置的,您可以停用统一存储桶级访问权限。
=sxx,其中 xx 是 0-2560 范围内的整数,表示图片最长边的长度(以像素为单位)。例如,如果添加 =s32,则图片的最长边将被调整为 32 像素。
=sxx-c,其中 xx 是 0-2560 范围内的整数,表示剪裁后的图片大小(以像素为单位);-c 用于指示系统对图片进行剪裁。
# Resize the image to 32 pixels (aspect-ratio preserved)
http://lhx.ggpht.com/randomStringImageId=s32
# Crop the image to 32 pixels
http://lhx.ggpht.com/randomStringImageId=s32-c
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-06。"],[[["The Images API enables serving and manipulating images directly from Google Cloud Storage or Blobstore, with support for various formats like JPEG, PNG, and WEBP."],["Cloud Storage buckets must use fine-grained Access Control Lists for the Images API to function correctly; uniform bucket-level access can cause errors and should be disabled."],["The `image.ServingURL` function generates stable, public URLs for serving resized or cropped image thumbnails, offloading CPU and dynamic serving load from your application."],["Images can be dynamically resized or cropped by adding arguments such as `=sxx` or `=sxx-c` to the serving URL, where `xx` represents the desired pixel dimension."],["To properly remove images, you should use the `image.DeleteServingURL` function instead of directly deleting images from Cloud Storage or Blobstore, as direct deletion can leave images accessible through their serving URLs."]]],[]]