public function singlePhoto($id) { $photoInfo = $this->request('flickr.photos.getInfo', array('photo_id' => $id)); //print_r($photoInfo); echo " " . $photoInfo->photo->id . " -- " . $photoInfo->photo->title->_content . "\n"; // Compile required info. $dateTaken = $photoInfo->photo->dates->taken; $description = ''; if ($photoInfo->photo->description->_content) { $description = trim($photoInfo->photo->description->_content, ' .') . '.'; } $photoDatum = array('id' => $id, 'user_id' => $photoInfo->photo->owner->nsid, 'date_taken_value' => $dateTaken, 'granularity' => $photoInfo->photo->dates->takengranularity, 'date_taken' => Latex::flickrDate($dateTaken, $photoInfo->photo->dates->takengranularity), 'title' => trim($photoInfo->photo->title->_content, '.') . '.', 'description' => $description, 'tags' => array()); foreach ($photoInfo->photo->tags->tag as $tag) { $photoDatum['tags'][] = $tag->raw; } $localDir = $this->dataDir . "/photos/{$id}"; if (!is_dir($localDir)) { mkdir($localDir, 0755, true); } // Download files. $farm = $photoInfo->photo->farm; $server = $photoInfo->photo->server; $scrt = $photoInfo->photo->secret; // Original? if (isset($photoInfo->photo->originalsecret)) { $origScrt = $photoInfo->photo->originalsecret; $origFmt = $photoInfo->photo->originalformat; $origUrl = 'https://farm' . $farm . '.staticflickr.com/' . $server . '/' . $id . '_' . $origScrt . '_o.' . $origFmt; if (!file_exists($localDir . '/original.' . $origFmt)) { file_put_contents($localDir . '/original.' . $origFmt, file_get_contents($origUrl)); } } // Medium. https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}_[mstzb].jpg $medUrl = 'https://farm' . $farm . '.staticflickr.com/' . $server . '/' . $id . '_' . $scrt . '_c.jpg'; if (!file_exists($localDir . '/medium.jpg')) { file_put_contents($localDir . '/medium.jpg', file_get_contents($medUrl)); } // Metadata. $metadata = Yaml::dump($photoDatum); file_put_contents($localDir . '/metadata.yml', $metadata); return $photoDatum; }
\begin{document} \maketitle \frontmatter \listoffigures \mainmatter \chapter{Photographs} <?php $img_count = 0; foreach ($photoData as $photo) { $title = Latex::texEsc($photo['title']); echo '\\begin{figure}' . "\n" . ' \\begin{center}' . "\n" . ' \\includegraphics{' . $dataDir . '/photos/' . $photo['id'] . '/medium.jpg}' . "\n" . ' \\caption[' . $photo['date_taken'] . ': ' . $title . ']' . '{' . $photo['date_taken'] . ': \\textbf{' . $title . '}' . "\n"; echo ' ' . Latex::texEsc($photo['description']); if (count($tags = $photo['tags']) > 0) { $tag_links = array(); foreach ($tags as $tag) { $t = Latex::texEsc($tag); $tag_links[] = '\\index{' . $t . '} \\textsc{' . $t . '}'; } echo ' {\\small ' . join(', ', $tag_links) . "}\n"; } $url = 'https://www.flickr.com/photos/' . $photo['user_id'] . '/' . $photo['id']; echo ' \\hfill {\\tiny \\href{' . $url . '}{' . $photo['id'] . '}}' . "\n"; echo " } % End caption\n" . " \\end{center}\n" . "\\end{figure}\n\n"; if ($img_count > 0 && $img_count % 12 == 0) { echo '\\clearpage'; } $img_count++; } ?> \printindex