コード例 #1
0
ファイル: image.php プロジェクト: bl00m/ampache
                $defaultimg .= "blankmovie.png";
                break;
            default:
                $mime = 'image/png';
                $defaultimg .= "blankalbum.png";
                break;
        }
        $image = file_get_contents($defaultimg);
    } else {
        if ($_GET['thumb']) {
            $thumb_data = $art->get_thumb($size);
            $etag .= '-' . $_GET['thumb'];
        }
        $mime = isset($thumb_data['thumb_mime']) ? $thumb_data['thumb_mime'] : $art->raw_mime;
        $image = isset($thumb_data['thumb']) ? $thumb_data['thumb'] : $art->raw;
    }
}
if (!empty($image)) {
    $extension = Art::extension($mime);
    $filename = scrub_out($filename . '.' . $extension);
    // Send the headers and output the image
    $browser = new Horde_Browser();
    if (!empty($etag)) {
        header('ETag: ' . $etag);
        header('Cache-Control: private');
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time()));
    }
    header("Access-Control-Allow-Origin: *");
    $browser->downloadHeaders($filename, $mime, true);
    echo $image;
}
コード例 #2
0
ファイル: catalog.class.php プロジェクト: axelsimon/ampache
 /**
  * dump_album_art
  *
  * This runs through all of the albums and tries to dump the
  * art for them into the 'folder.jpg' file in the appropriate dir.
  */
 public function dump_album_art($methods = array())
 {
     // Get all of the albums in this catalog
     $albums = $this->get_album_ids();
     echo "Starting Dump Album Art...\n";
     $i = 0;
     // Run through them and get the art!
     foreach ($albums as $album_id) {
         $album = new Album($album_id);
         $art = new Art($album_id, 'album');
         if (!$art->get_db()) {
             continue;
         }
         // Get the first song in the album
         $songs = $album->get_songs(1);
         $song = new Song($songs[0]);
         $dir = dirname($song->file);
         $extension = Art::extension($art->raw_mime);
         // Try the preferred filename, if that fails use folder.???
         $preferred_filename = AmpConfig::get('album_art_preferred_filename');
         if (!$preferred_filename || strpos($preferred_filename, '%') !== false) {
             $preferred_filename = "folder.{$extension}";
         }
         $file = "{$dir}/{$preferred_filename}";
         if ($file_handle = fopen($file, "w")) {
             if (fwrite($file_handle, $art->raw)) {
                 // Also check and see if we should write
                 // out some metadata
                 if ($methods['metadata']) {
                     switch ($methods['metadata']) {
                         case 'windows':
                             $meta_file = $dir . '/desktop.ini';
                             $string = "[.ShellClassInfo]\nIconFile={$file}\nIconIndex=0\nInfoTip={$album->full_name}";
                             break;
                         case 'linux':
                         default:
                             $meta_file = $dir . '/.directory';
                             $string = "Name={$album->full_name}\nIcon={$file}";
                             break;
                     }
                     $meta_handle = fopen($meta_file, "w");
                     fwrite($meta_handle, $string);
                     fclose($meta_handle);
                 }
                 // end metadata
                 $i++;
                 if (!($i % 100)) {
                     echo "Written: {$i}. . .\n";
                     debug_event('art_write', "{$album->name} Art written to {$file}", '5');
                 }
             } else {
                 debug_event('art_write', "Unable to open {$file} for writing", 5);
                 echo "Error: unable to open file for writing [{$file}]\n";
             }
         }
         fclose($file_handle);
     }
     echo "Album Art Dump Complete\n";
 }