// Get AdWordsUser from "~/adwords.properties".
AdWordsUser user = new AdWordsUser();
// Get the MediaService.
MediaServiceInterface mediaService =
user.getService(AdWordsService.V201306.MEDIA_SERVICE);
// Create selector.
Selector selector = new Selector();
selector.setFields(new String[] {"MediaId", "Width", "Height", "MimeType"});
selector.setOrdering(new OrderBy[] {new OrderBy("MediaId", SortOrder.ASCENDING)});
// Create predicates.
Predicate typePredicate =
new Predicate("Type", PredicateOperator.IN, new String[] {"IMAGE"});
selector.setPredicates(new Predicate[] {typePredicate});
// Get all images.
MediaPage page = mediaService.get(selector);
// Display images.
if (page != null && page.getEntries() != null) {
for (Media image : page.getEntries()) {
Map<MediaSize, Dimensions> dimensions = MapUtils.toMap(image.getDimensions());