salve, il mio intento da niubbo nell'uso di java è quello di riuscire attraverso le api di flickr a scaricare un immagine dal sito contenente i tag su hard disk, per ora riesco a scaricare solo il file stesso e riesco anche a estrarre un vector contenente i vari tag dell'immagine, quello che non riesco a fare e salvare entrambe le info sul file .jpg...
qualcune sa come posso fare? il codice è il seguente:
qualsiasi aiuto sarà bene accetto..
codice:public void download() throws ParserConfigurationException, SAXException, IOException, FlickrException { //Set api key String key = "dc4b753de7a55497acc7723cbc0e0fed"; String svr = "www.flickr.com"; REST rest = new REST(); rest.setHost(svr); //initialize Flickr object with key and rest Flickr flickr = new Flickr(key, rest); Flickr.debugStream = false; //initialize SearchParameter object, this object stores the search keyword SearchParameters searchParams = new SearchParameters(); searchParams.setSort(SearchParameters.INTERESTINGNESS_DESC); //Create tag keyword array String[] tags = new String[]{"dog", "beagle"}; searchParams.setTags(tags); //Initialize PhotosInterface object PhotosInterface photosInterface = flickr.getPhotosInterface(); //Execute search with entered tags PhotoList photoList; photoList = photosInterface.search(searchParams, 1, 1); //get search result and fetch the photo object and get small square imag's url if (photoList != null) { //Get search result and check the size of photo result for (int i = 0; i < photoList.size(); i++) { Photo photo = (Photo) photoList.get(i); photo = photosInterface.getPhoto(photo.getId()); RenderedImage im = photosInterface.getImage(photo, 4); Photo tag = flickr.getTagsInterface().getListPhoto(photo.getId()); Vector tagList = new Vector(tag.getTags()); //??????? System.out.println(tagList.size()); for (int j = 0; j < tagList.size(); j++) { Tag t = (Tag) tagList.get(j); System.out.println(t.getValue()); } File outputFile = new File("c:/database immagini/image0" + i + ".jpg"); ImageIO.write(im, "jpg", outputFile); } } } }

Rispondi quotando