Created
February 17, 2011 01:10
-
-
Save issm/830712 to your computer and use it in GitHub Desktop.
generates EAN13/Code39 barcode easily.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plackup -s Starman --port 5000 -MGD::Barcode -MGD::Image -MPlack::Request -e 'my $app = sub { my $q = Plack::Request->new(shift)->query_parameters(); my ($c,$m,$r,$h,$nt) = split(/:/,$q->get("q")||""); my $bc = GD::Barcode->new($m||"EAN13",$c) or return [500,["Content-Type"=>"text/plain"],[$GD::Barcode::errStr]]; my ($i0,$i1) = ($bc->plot(Height=>$h,NoText=>$nt)); my ($w0,$h0) = $i0->getBounds(); my ($w1,$h1) = (int($w0*($r||1)),int($h0*($r||1))); $i1 = GD::Image->new($w1,$h1); $i1->copyResized($i0,0,0,0,0,$w1,$h1,$w0,$h0); return [200,["Content-Type"=>"image/png"],[$i1->png]]; }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment