A friend and I are trying to create a Photomosaic generator in Processing. We want to be able to pull 100 images from Google using the Custom Search API, restricting the image size and dominant color, along with few other things. We want to save these images so that we can process them in our program. We also want to use data that will come from the GUI to be used to build the API call, i.e the search keyword.
The following code snippet shows what parameters we want to constrain our image search with:
var searcher = new google.search.customSearchControl.getImageSearcher();
searcher.setRestriction(
google.search.Search.RESTRICT_SAFESEARCH,
google.search.Search.SAFESEARCH_STRICT
);
searcher.setRestriction(
google.search.customSearchControl.getImageSearcher.RESTRICT_IMAGESIZE,
google.search.customSearchControl.getImageSearcher.IMAGESIZE_MEDUIM
);
searcher.setRestriction(
google.search.customSearchControl.getImageSearcher.RESTRICT_COLORFILTER,
google.search.customSearchControl.getImageSearcher.COLOR_RED
);
searcher.execute(keyword);
We just aren't sure how to restrict the number of search results or what format the data returns in. Is it JSON?
This is if you are building a URL, and not doing it programatically.
JSON
as the return value, append &alt=json
to the end of your request URL.num=50
as one of the parametersSource: https://developers.google.com/custom-search/v1/using_rest#query-params