$name_field_width) { $NAME_FONT_SIZE = $NAME_FONT_SIZE - 1; $namebox = imagettfbbox($NAME_FONT_SIZE, 0, $font_path, $NAME); } # center the name text box $namebox_h = $namebox[1] - $namebox[7]; # y of down left edge - y of up left edge $namebox_y = $margin_name_top + ($name_field_height/2) + ($namebox_h/2); imagefttext($badge, $NAME_FONT_SIZE, 0, $margin_name_left, $namebox_y, $font_color, $font_path, $NAME); # adjust font size for the pronouns $pronbox = imagettfbbox($PRONOUN_FONT_SIZE, 0, $font_path, $PRONOUNS); while (($pronbox[2] - $pronbox[0]) > $pron_field_width) { $PRONOUN_FONT_SIZE = $PRONOUN_FONT_SIZE - 1; $pronbox = imagettfbbox($PRONOUN_FONT_SIZE, 0, $font_path, $PRONOUNS); } # center the pronoun text box $pronbox_h = $pronbox[1] - $pronbox[7]; $pronbox_y = $margin_pron_top + ($pron_field_height/2) + ($pronbox_h/2); imagefttext($badge, $PRONOUN_FONT_SIZE, 0, $margin_pron_left, $pronbox_y, $font_color, $font_path, $PRONOUNS); # display image //header('Content-Type: image/png'); imagefilter($badge, IMG_FILTER_GRAYSCALE); if(imagepng($badge, $written_badge_path.$written_badge_ext)) { imagedestroy($badge); # convert and print image $printable_file = $written_badge_path."_".$written_badge_ext; $cmd_convert = "convert ".$written_badge_path.$written_badge_ext." -background white -alpha remove -compose copy_opacity -resize x720 -monochrome ".$printable_file; #$cmd_convert = "convert uploads/badge.png -background white -alpha remove -compose copy_opacity -resize x720 -monochrome uploads/badge_.png"; #$cmd_print = "./ql570 /dev/usb/lp0 w uploads/badge_.png"; $cmd_print = "./ql570 ".$print_dev." w ".$printable_file; $output_convert = shell_exec($cmd_convert); $output_print = shell_exec($cmd_print); } else { echo "Badge could not be created"; } } else { echo "No name has been set"; } } else { echo "GD library is not installed"; } if($debug == false) { header('Location: http://'.$_SERVER['HTTP_HOST']); } ?>