Flickr Compositor

tagSearch($keywords, array('per_page' => 50, 'tag_mode' => 'all')); if ($results->totalResults() > 0) { $images = array(); foreach ($results as $result) { if (isset($result->Medium)) { $images[] = imagecreatefromjpeg($result->Medium->uri); $heights[] = $result->Medium->height; $widths[] = $result->Medium->width; } } if (sizeof($images) == 0) { echo '

No Results Found.

'; } else { sort($heights); sort($widths); $max_height = array_pop($heights); $max_width = array_pop($widths); $output = realpath("./temp/") .DIRECTORY_SEPARATOR.mt_rand(). ".jpg"; foreach ($images as $key => $image) { if (!file_exists('./temp')) { mkdir("./temp"); } $tmp = tempnam(realpath('./temp'), 'zflickr'); imagejpeg($image, $tmp); chmod($tmp, 0777); if (file_exists($output)) { passthru("composite -dissolve 20 $tmp $output $output"); chmod($output, 0777); } elseif (!isset($previous_image)) { $previous_image = "$tmp"; } else { passthru("composite -dissolve 20 $tmp $previous_image $output"); chmod($output, 0777); } $image_files[] = $tmp; } foreach ($image_files as $filename) { unlink($filename); } //copy($output, basename($output)); //unlink($output); $size = getimagesize($output); $size[0] += 25; $size[1] += 25; echo "
" .htmlspecialchars($keywords). "

" .ucwords(htmlspecialchars($keywords)). "

"; } } else { echo '

No Results Found

'; } } catch (Zend_Service_Exception $e) { echo '

An error occured, please try again later. (' .$e->getMessage(). ')

'; } } ?>

Powered by the Zend Framework