PHP 5 has reached end of support and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy PHP 5
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing PHP
5 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you migrate to the latest supported version of PHP.
Stay organized with collections
Save and categorize content based on your preferences.
The App Engine API for Cloud Storage Tools provides convenience methods
for serving image files:
CloudStorageTools.getImageServingUrl()
CloudStorageTools.deleteImageServingUrl()
One advantage of using this method to serve images over simply
making the files public is
the ability to resize and crop dynamically, without needing to store the
images in different sizes.
CloudStorageTools::getImageServingUrl
returns a serving URL for an image. If the image will be displayed within an
HTTPS page, set secure_url to True to avoid mixed-content warnings.
Notice that this URL is publicly readable by everyone, but it is not "guessable".
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eThe App Engine API offers \u003ccode\u003eCloudStorageTools.getImageServingUrl()\u003c/code\u003e to generate URLs for serving images stored in Cloud Storage, and \u003ccode\u003eCloudStorageTools.deleteImageServingUrl()\u003c/code\u003e to stop serving them.\u003c/p\u003e\n"],["\u003cp\u003eUsing \u003ccode\u003egetImageServingUrl\u003c/code\u003e allows for dynamic resizing and cropping of images without needing to store multiple image sizes, offering a significant advantage over directly making files public.\u003c/p\u003e\n"],["\u003cp\u003eOnly the first app that calls \u003ccode\u003egetImageServingUrl\u003c/code\u003e can serve a specific image; subsequent apps must copy the image first if they need to serve it.\u003c/p\u003e\n"],["\u003cp\u003eSetting \u003ccode\u003esecure_url\u003c/code\u003e to \u003ccode\u003eTrue\u003c/code\u003e when using \u003ccode\u003egetImageServingUrl\u003c/code\u003e ensures the image can be displayed on HTTPS pages without mixed-content warnings.\u003c/p\u003e\n"],["\u003cp\u003eTo remove the actual file you must use the PHP \u003ccode\u003eunlink()\u003c/code\u003e function and not the \u003ccode\u003edeleteImageServingUrl\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Serving Images\n\nThe App Engine API for Cloud Storage Tools provides convenience methods\nfor serving image files:\n\n- `CloudStorageTools.getImageServingUrl()`\n- `CloudStorageTools.deleteImageServingUrl()`\n\n| This page describes how to use the legacy bundled services and APIs. This API can only run in first-generation runtimes in the App Engine standard environment. If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\n\n\u003cbr /\u003e\n\n| **Note:** When running your app locally on the [development server](/appengine/docs/legacy/standard/php/tools/using-local-server), you'll need to install [PIL](https://python-pillow.org/) if you wish to use the image sizing options described in this page.\n\nOne advantage of using this method to serve images over simply\n[making the files public](/appengine/docs/legacy/standard/php/googlestorage/public_access) is\nthe ability to resize and crop dynamically, without needing to store the\nimages in different sizes.\n\n[CloudStorageTools::getImageServingUrl](/appengine/docs/legacy/standard/php/refdocs/classes/google.appengine.api.cloud_storage.CloudStorageTools#method_getImageServingUrl)\nreturns a serving URL for an image. If the image will be displayed within an\nHTTPS page, set `secure_url` to `True` to avoid mixed-content warnings.\n\nNotice that this URL is publicly readable by everyone, but it is not \"guessable\".\n| **Important:** You cannot serve an image from two separate apps; only the first app that calls `getImageServingUrl` can get the URL to serve it because that app has obtained ownership of the image to serve it. Any other app that calls `getImageServingUrl` on the image will therefore be unsuccessful. If a second app needs to serve the image, the app needs to first copy the image and then invoke `getImageServingUrl` on the copy.\n\nTo stop serving the URL,\ncall [CloudStorageTools::deleteImageServingUrl](/appengine/docs/legacy/standard/php/refdocs/classes/google.appengine.api.cloud_storage.CloudStorageTools#method_deleteImageServingUrl).\n| **Note:** If you want to delete the file itself, use the PHP `unlink()` function.\n\nTo use this feature, import the `CloudStorageTools` class: \n\n use google\\appengine\\api\\cloud_storage\\CloudStorageTools;\n\nNow resize and crop the image `image.jpg`: \n\n $options = ['size' =\u003e 400, 'crop' =\u003e true];\n $image_file = \"gs://${my_bucket}/image.jpg\";\n $image_url = CloudStorageTools::getImageServingUrl($image_file, $options);"]]