function asGDImage($text,$resize=160){
        $barcode = $this->encode($text);
        $w  = $barcode['width'];
        $h  = $barcode['height'];
        $bs = 10;
        $size  = $bs * $w;

        $img   = imagecreatetruecolor($size + 2 * $bs * 2 ,$size + 2 * $bs * 2);
        $white = imagecolorallocate($img,255,255,255);
        $black = imagecolorallocate($img,0,0,0);
        imagefill($img,0,0,$white);

        for($j=0; $j < $h; $j++){
            for($i=0; $i < $w; $i++){
                $x1 = ($i * $bs) + $bs * 2;
                $y1 = ($size - (($j + 1) * $bs)) + $bs * 2;
                $x2 = $x1 + $bs;
                $y2 = $y1 + $bs;

                if($barcode['data'][$j * $w + $i]){
                    imagefilledrectangle($img,$x1,$y1,$x2,$y2,$black);
                } else {
                    imagefilledrectangle($img,$x1,$y1,$x2,$y2,$white);
                }
            }
        }

        if($resize == $size){
            return $img;
        }

        $new  = imagecreatetruecolor($resize,$resize);
        imagecopyresized($new, $img, 0, 0, 0, 0, $resize, $resize, $size + 2 * $bs * 2, $size + 2 * $bs * 2);
        imagedestroy($img);
        return $new;
    }