-5

I'm not an expert in Java.. I was wondering if there is a method, to get the first image of a result of searching an Image on Google Images from a String.

If yes, what is the easiest and fastest method to do it?

Thanks in advance!

OldTester
  • 1
  • 2
  • You can use the google custom search API https://developers.google.com/custom-search/json-api/v1/overview#prerequisites – explv Jul 06 '16 at 14:00

1 Answers1

1

Get an instance of the imagesService we can use to transform images:

ImagesService imagesService = ImagesServiceFactory.getImagesService();

Make an image directly from a byte array, and transform it:

Image image = ImagesServiceFactory.makeImage(imageBytes);
Transform resize = ImagesServiceFactory.makeResize(100, 50);
Image resizedImage = imagesService.applyTransform(resize, image);

Write the transformed image back to a Cloud Storage object:

gcsService.createOrReplace(
    new GcsFilename(bucket, "resizedImage.jpeg"),
    new GcsFileOptions.Builder().mimeType("image/jpeg").build(),
    ByteBuffer.wrap(resizedImage.getImageData()));
CloudPotato
  • 1,255
  • 1
  • 17
  • 32
Thurst
  • 15
  • 7
  • Hello. Thanks for the answer.. but, how can I get the first image found on google of a String? That was my question. – OldTester Jul 06 '16 at 14:09
  • Did you try this code, if not you should try it first and see how it works out for you – Thurst Jul 06 '16 at 14:12