// data values can range between 0 and 255 $v = (int) ($data[$d] / 255 * $height); // draw the line on the image using the $v value and centering it vertically on the canvas imageline($img, $d / $detail, 0 + ($height - $v), $d / $detail, $height - ($height - $v), imagecolorallocate($img, $r, $g, $b)); } //create file $fp = fopen('images/' . $finalFilename, 'w'); fclose($fp); // want it resized? if ($width) { // resample the image to the proportions defined in the form $rimg = imagecreatetruecolor($width, $height); imagecopyresampled($rimg, $img, 0, 0, 0, 0, $width, $height, sizeof($data) / $detail, $height); imagepng($rimg, 'images/' . $finalFilename); imagedestroy($rimg); } else { // print out at it's raw width (size of $data / detail level) imagepng($img, 'images/' . $finalFilename); imagedestroy($img); } return 'images/' . $finalFilename; } if (isset($_GET['filename'])) { ini_set("max_execution_time", "60000"); echo 'analyzing file' . $_GET['filename']; mp3toWavForm($_GET['filename']); echo 'done!'; } ?>
public function buildFiles($dir) { $fileIterator = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)), '/\\.mp3$/'); $files = array(); foreach ($fileIterator as $index => $file) { $files[$index]['filePath'] = htmlspecialchars($file->getPath() . '/' . $file->getFilename()); $files[$index]['fileName'] = htmlspecialchars($file->getFilename()); $files[$index]['info'] = $this->id3->analyze($file->getPath() . '/' . $file->getFilename()); unset($files[$index]['info']['comments']); unset($files[$index]['info']['id3v2']['APIC']); unset($files[$index]['info']['mpeg']); if (!file_exists('images/' . self::getImageName($file->getFilename()))) { $files[$index]['imagePath'] = mp3toWavForm($file->getPath() . '/' . $file->getFilename()); } else { $files[$index]['imagePath'] = 'images/' . self::getImageName($file->getFilename()); } } return $files; }