Skip to content

Commit

Permalink
Fixed to not resize if no image width specified
Browse files Browse the repository at this point in the history
  • Loading branch information
afreiday committed Dec 12, 2011
1 parent 9bcbb64 commit fca2983
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions php-waveform-png.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ function html2rgb($input) {
unlink($filename);

}

header("Content-Type: image/png");

// want it resized?
if ($width) {
Expand All @@ -219,12 +221,12 @@ function html2rgb($input) {
imagealphablending($rimg, false);
// copy to resized
imagecopyresampled($rimg, $img, 0, 0, 0, 0, $width, $height, imagesx($img), imagesy($img));
imagepng($rimg);
imagedestroy($rimg);
} else {
imagepng($img);
}

header("Content-Type: image/png");

imagepng($rimg);
imagedestroy($rimg);
imagedestroy($img);

} else {
Expand Down

1 comment on commit fca2983

@yanglihui
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ratio = ($channel == 2 ? 40 : 80);
// start putting together the initial canvas
// $data_size = (size_of_file - header_bytes_read) / skipped_bytes + 1
$data_size = floor((filesize($filename) - 44) / ($ratio + $byte) + 1);

would you tell me why channel = 2 skip 40 and channel = 1 skip 80?

Please sign in to comment.