Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
* <img src="/barcode.php?text=testing" alt="testing" />
*/

// Get pararameters that are passed in through $_GET or set to the default value
$text = (isset($_GET["text"])?$_GET["text"]:"0");
$size = (isset($_GET["size"])?$_GET["size"]:"20");
$orientation = (isset($_GET["orientation"])?$_GET["orientation"]:"horizontal");
$code_type = (isset($_GET["codetype"])?$_GET["codetype"]:"code128");
function barcode($filepath="",$text="0",$size="20",$orientation="horizontal",$code_type="code128") {
$code_string = "";

// Translate the $text into barcode the correct $code_type
Expand Down Expand Up @@ -107,8 +103,14 @@
imagefilledrectangle( $image, 0, $location, $img_width, $cur_size, ($position % 2 == 0 ? $white : $black) );
$location = $cur_size;
}
// Draw barcode to the screen
header ('Content-type: image/png');
imagepng($image);
imagedestroy($image);
// Draw barcode to the screen or save in a file
if($filepath=="") {
header ('Content-type: image/png');
imagepng($image);
imagedestroy($image);
} else {
imagepng($image,$filepath);
imagedestroy($image);
}
}
?>