GitHub Repository | Product Reference |
Service Description: Service that exposes Generative AI (GenAI) endpoints for creating and enhancing product image content.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
String name = "name3373707";
GenerateProductImageBackgroundResponse response =
imageServiceClient.generateProductImageBackground(name);
}
Note: close() needs to be called on the ImageServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
Method | Description | Method Variants |
---|---|---|
GenerateProductImageBackground |
GenerateProductImageBackground generates a new image where the background of the original image is replaced by an AI generated scene based on provided product information and a text prompt. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RemoveProductImageBackground |
RemoveProductImageBackground generates a new image where the background of the original image is removed. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpscaleProductImage |
UpscaleProductImage generates a new image where the resolution of the original image is enhanced. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ImageServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ImageServiceSettings imageServiceSettings =
ImageServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ImageServiceClient imageServiceClient = ImageServiceClient.create(imageServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ImageServiceSettings imageServiceSettings =
ImageServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ImageServiceClient imageServiceClient = ImageServiceClient.create(imageServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ImageServiceSettings imageServiceSettings = ImageServiceSettings.newHttpJsonBuilder().build();
ImageServiceClient imageServiceClient = ImageServiceClient.create(imageServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final ImageServiceClient create()
Constructs an instance of ImageServiceClient with default settings.
Returns | |
---|---|
Type | Description |
ImageServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(ImageServiceSettings settings)
public static final ImageServiceClient create(ImageServiceSettings settings)
Constructs an instance of ImageServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Parameter | |
---|---|
Name | Description |
settings |
ImageServiceSettings |
Returns | |
---|---|
Type | Description |
ImageServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(ImageServiceStub stub)
public static final ImageServiceClient create(ImageServiceStub stub)
Constructs an instance of ImageServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ImageServiceSettings).
Parameter | |
---|---|
Name | Description |
stub |
ImageServiceStub |
Returns | |
---|---|
Type | Description |
ImageServiceClient |
Constructors
ImageServiceClient(ImageServiceSettings settings)
protected ImageServiceClient(ImageServiceSettings settings)
Constructs an instance of ImageServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Parameter | |
---|---|
Name | Description |
settings |
ImageServiceSettings |
ImageServiceClient(ImageServiceStub stub)
protected ImageServiceClient(ImageServiceStub stub)
Parameter | |
---|---|
Name | Description |
stub |
ImageServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Parameters | |
---|---|
Name | Description |
duration |
long |
unit |
TimeUnit |
Returns | |
---|---|
Type | Description |
boolean |
Exceptions | |
---|---|
Type | Description |
InterruptedException |
close()
public final void close()
generateProductImageBackground(GenerateProductImageBackgroundRequest request)
public final GenerateProductImageBackgroundResponse generateProductImageBackground(GenerateProductImageBackgroundRequest request)
GenerateProductImageBackground generates a new image where the background of the original image is replaced by an AI generated scene based on provided product information and a text prompt.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
GenerateProductImageBackgroundRequest request =
GenerateProductImageBackgroundRequest.newBuilder()
.setName("name3373707")
.setOutputConfig(OutputImageConfig.newBuilder().build())
.setInputImage(InputImage.newBuilder().build())
.setConfig(GenerateImageBackgroundConfig.newBuilder().build())
.build();
GenerateProductImageBackgroundResponse response =
imageServiceClient.generateProductImageBackground(request);
}
Parameter | |
---|---|
Name | Description |
request |
GenerateProductImageBackgroundRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
GenerateProductImageBackgroundResponse |
generateProductImageBackground(String name)
public final GenerateProductImageBackgroundResponse generateProductImageBackground(String name)
GenerateProductImageBackground generates a new image where the background of the original image is replaced by an AI generated scene based on provided product information and a text prompt.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
String name = "name3373707";
GenerateProductImageBackgroundResponse response =
imageServiceClient.generateProductImageBackground(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. The account for which to generate an image. This acts as a container for the request and does not affect the generation itself. Format: accounts/{account} |
Returns | |
---|---|
Type | Description |
GenerateProductImageBackgroundResponse |
generateProductImageBackgroundCallable()
public final UnaryCallable<GenerateProductImageBackgroundRequest,GenerateProductImageBackgroundResponse> generateProductImageBackgroundCallable()
GenerateProductImageBackground generates a new image where the background of the original image is replaced by an AI generated scene based on provided product information and a text prompt.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
GenerateProductImageBackgroundRequest request =
GenerateProductImageBackgroundRequest.newBuilder()
.setName("name3373707")
.setOutputConfig(OutputImageConfig.newBuilder().build())
.setInputImage(InputImage.newBuilder().build())
.setConfig(GenerateImageBackgroundConfig.newBuilder().build())
.build();
ApiFuture<GenerateProductImageBackgroundResponse> future =
imageServiceClient.generateProductImageBackgroundCallable().futureCall(request);
// Do something.
GenerateProductImageBackgroundResponse response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<GenerateProductImageBackgroundRequest,GenerateProductImageBackgroundResponse> |
getSettings()
public final ImageServiceSettings getSettings()
Returns | |
---|---|
Type | Description |
ImageServiceSettings |
getStub()
public ImageServiceStub getStub()
Returns | |
---|---|
Type | Description |
ImageServiceStub |
isShutdown()
public boolean isShutdown()
Returns | |
---|---|
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Returns | |
---|---|
Type | Description |
boolean |
removeProductImageBackground(RemoveProductImageBackgroundRequest request)
public final RemoveProductImageBackgroundResponse removeProductImageBackground(RemoveProductImageBackgroundRequest request)
RemoveProductImageBackground generates a new image where the background of the original image is removed.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
RemoveProductImageBackgroundRequest request =
RemoveProductImageBackgroundRequest.newBuilder()
.setName("name3373707")
.setOutputConfig(OutputImageConfig.newBuilder().build())
.setInputImage(InputImage.newBuilder().build())
.setConfig(RemoveImageBackgroundConfig.newBuilder().build())
.build();
RemoveProductImageBackgroundResponse response =
imageServiceClient.removeProductImageBackground(request);
}
Parameter | |
---|---|
Name | Description |
request |
RemoveProductImageBackgroundRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
RemoveProductImageBackgroundResponse |
removeProductImageBackground(String name)
public final RemoveProductImageBackgroundResponse removeProductImageBackground(String name)
RemoveProductImageBackground generates a new image where the background of the original image is removed.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
String name = "name3373707";
RemoveProductImageBackgroundResponse response =
imageServiceClient.removeProductImageBackground(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. The account for which to generate an image. This acts as a container for the request and does not affect the generation itself. Format: accounts/{account} |
Returns | |
---|---|
Type | Description |
RemoveProductImageBackgroundResponse |
removeProductImageBackgroundCallable()
public final UnaryCallable<RemoveProductImageBackgroundRequest,RemoveProductImageBackgroundResponse> removeProductImageBackgroundCallable()
RemoveProductImageBackground generates a new image where the background of the original image is removed.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
RemoveProductImageBackgroundRequest request =
RemoveProductImageBackgroundRequest.newBuilder()
.setName("name3373707")
.setOutputConfig(OutputImageConfig.newBuilder().build())
.setInputImage(InputImage.newBuilder().build())
.setConfig(RemoveImageBackgroundConfig.newBuilder().build())
.build();
ApiFuture<RemoveProductImageBackgroundResponse> future =
imageServiceClient.removeProductImageBackgroundCallable().futureCall(request);
// Do something.
RemoveProductImageBackgroundResponse response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<RemoveProductImageBackgroundRequest,RemoveProductImageBackgroundResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
upscaleProductImage(UpscaleProductImageRequest request)
public final UpscaleProductImageResponse upscaleProductImage(UpscaleProductImageRequest request)
UpscaleProductImage generates a new image where the resolution of the original image is enhanced.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
UpscaleProductImageRequest request =
UpscaleProductImageRequest.newBuilder()
.setName("name3373707")
.setOutputConfig(OutputImageConfig.newBuilder().build())
.setInputImage(InputImage.newBuilder().build())
.build();
UpscaleProductImageResponse response = imageServiceClient.upscaleProductImage(request);
}
Parameter | |
---|---|
Name | Description |
request |
UpscaleProductImageRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
UpscaleProductImageResponse |
upscaleProductImage(String name)
public final UpscaleProductImageResponse upscaleProductImage(String name)
UpscaleProductImage generates a new image where the resolution of the original image is enhanced.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
String name = "name3373707";
UpscaleProductImageResponse response = imageServiceClient.upscaleProductImage(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. The account for which to generate an image. This acts as a container for the request and does not affect the generation itself. Format: accounts/{account} |
Returns | |
---|---|
Type | Description |
UpscaleProductImageResponse |
upscaleProductImageCallable()
public final UnaryCallable<UpscaleProductImageRequest,UpscaleProductImageResponse> upscaleProductImageCallable()
UpscaleProductImage generates a new image where the resolution of the original image is enhanced.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ImageServiceClient imageServiceClient = ImageServiceClient.create()) {
UpscaleProductImageRequest request =
UpscaleProductImageRequest.newBuilder()
.setName("name3373707")
.setOutputConfig(OutputImageConfig.newBuilder().build())
.setInputImage(InputImage.newBuilder().build())
.build();
ApiFuture<UpscaleProductImageResponse> future =
imageServiceClient.upscaleProductImageCallable().futureCall(request);
// Do something.
UpscaleProductImageResponse response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<UpscaleProductImageRequest,UpscaleProductImageResponse> |