Class LocalImagesService
java.lang.Object
com.google.appengine.tools.development.AbstractLocalRpcService
com.google.appengine.api.images.dev.LocalImagesService
- All Implemented Interfaces:
LocalRpcService
@AutoService(LocalRpcService.class)
public final class LocalImagesService
extends AbstractLocalRpcService
Java stub implementation of the images api backend using Image 2D. Depends on ImageIO being able
to load and save in the correct image formats.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.appengine.tools.development.LocalRpcService
LocalRpcService.Status -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.google.appengine.api.images.ImagesServicePb.ImagesCompositeResponsecomposite(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesCompositeRequest request) com.google.appengine.api.images.ImagesServicePb.ImagesDeleteUrlBaseResponsedeleteUrlBase(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesDeleteUrlBaseRequest request) Returns the maximum size of an encoded API request in bytes, ornullfor the default size.getMimeType(com.google.appengine.api.images.ImagesServicePb.ImageData imageData) Obtains the mime type of the image data.Returns the package for the service, for example, "datastore_v3".com.google.appengine.api.images.ImagesServicePb.ImagesGetUrlBaseResponsegetUrlBase(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesGetUrlBaseRequest request) Gets a Local image URL.com.google.appengine.api.images.ImagesServicePb.ImagesHistogramResponsehistogram(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesHistogramRequest request) Calculate the histogram of the supplied image.voidinit(LocalServiceContext context, Map<String, String> properties) Initializes the service with a set of configuration properties.openImage(com.google.appengine.api.images.ImagesServicePb.ImageData imageData, LocalRpcService.Status status) Loads an image represented by a byte array into aBufferedImage.processTransform(BufferedImage image, com.google.appengine.api.images.ImagesServicePb.Transform transform, LocalRpcService.Status status) Apply an individual transform to the provided image.byte[]saveImage(BufferedImage image, com.google.appengine.api.images.ImagesServicePb.OutputSettings.MIME_TYPE mimeType, LocalRpcService.Status status) Saves aBufferedImageinto a byte array using themimeTypeencoding.voidstart()Puts a new service into "serving" mode.voidstop()Stops the service, releasing all of its resources.com.google.appengine.api.images.ImagesServicePb.ImagesTransformResponsetransform(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesTransformRequest request) Apply the transform request to the contained image.Methods inherited from class com.google.appengine.tools.development.AbstractLocalRpcService
getDefaultDeadline, getMaximumDeadline
-
Field Details
-
PACKAGE
The package name for this service.- See Also:
-
-
Constructor Details
-
LocalImagesService
public LocalImagesService()
-
-
Method Details
-
getPackage
Returns the package for the service, for example, "datastore_v3".- Returns:
- a not
nullpackage name.
-
init
Initializes the service with a set of configuration properties. Must be called before a service isstarted.- Specified by:
initin interfaceLocalRpcService- Overrides:
initin classAbstractLocalRpcService- Parameters:
context- A context object for the applicationproperties- A read-onlyMapof properties.
-
start
public void start()Puts a new service into "serving" mode. Aside from setting properties, the service is not functional until after having been started.- Specified by:
startin interfaceLocalRpcService- Overrides:
startin classAbstractLocalRpcService
-
stop
public void stop()Stops the service, releasing all of its resources.- Specified by:
stopin interfaceLocalRpcService- Overrides:
stopin classAbstractLocalRpcService
-
transform
public com.google.appengine.api.images.ImagesServicePb.ImagesTransformResponse transform(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesTransformRequest request) Apply the transform request to the contained image.- Parameters:
status- RPC statusrequest- request to be processed- Returns:
- a transform response containing the processed image
-
composite
public com.google.appengine.api.images.ImagesServicePb.ImagesCompositeResponse composite(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesCompositeRequest request) - Parameters:
status- RPC statusrequest- request to be processed- Returns:
- a transform response containing the processed image
-
getMimeType
Obtains the mime type of the image data.- Parameters:
imageData- a reference to the image- Returns:
- a string representing the mime type. Valid return values include
inputFormatsin LocalImagesService.init(). - Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- If the image cannot be opened
-
openImage
public BufferedImage openImage(com.google.appengine.api.images.ImagesServicePb.ImageData imageData, LocalRpcService.Status status) Loads an image represented by a byte array into aBufferedImage.- Parameters:
imageData- A byte array representing an imagestatus- RPC status- Returns:
- a
BufferedImageof the image. - Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- If the image cannot be opened.
-
saveImage
public byte[] saveImage(BufferedImage image, com.google.appengine.api.images.ImagesServicePb.OutputSettings.MIME_TYPE mimeType, LocalRpcService.Status status) Saves aBufferedImageinto a byte array using themimeTypeencoding.- Parameters:
image- the image to be encoded.status- RPC status.- Returns:
- A byte array representing an image.
- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- If the image cannot be encoded.
-
histogram
public com.google.appengine.api.images.ImagesServicePb.ImagesHistogramResponse histogram(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesHistogramRequest request) Calculate the histogram of the supplied image.- Parameters:
status- RPC statusrequest- request to be processed- Returns:
- a histogram response containing the histogram of the image
-
getUrlBase
public com.google.appengine.api.images.ImagesServicePb.ImagesGetUrlBaseResponse getUrlBase(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesGetUrlBaseRequest request) Gets a Local image URL.- Parameters:
status- RPC statusrequest- request containing the blobkey to be served- Returns:
- a response containing the Local image Url
-
deleteUrlBase
public com.google.appengine.api.images.ImagesServicePb.ImagesDeleteUrlBaseResponse deleteUrlBase(LocalRpcService.Status status, com.google.appengine.api.images.ImagesServicePb.ImagesDeleteUrlBaseRequest request) -
getMaxApiRequestSize
Description copied from interface:LocalRpcServiceReturns the maximum size of an encoded API request in bytes, ornullfor the default size.- Specified by:
getMaxApiRequestSizein interfaceLocalRpcService- Overrides:
getMaxApiRequestSizein classAbstractLocalRpcService
-
processTransform
public BufferedImage processTransform(BufferedImage image, com.google.appengine.api.images.ImagesServicePb.Transform transform, LocalRpcService.Status status) Apply an individual transform to the provided image.- Parameters:
image- image to be processedtransform- transform to be applied to the imagestatus- RPC status- Returns:
- processed image
-