Permalink
Browse files

adding svg export support and file writing support

  • Loading branch information...
1 parent 57ef45a commit 7632c7e525586dd992fb4d1b395fadeb4f94391e @t0k4rt committed Feb 9, 2012
Showing with 292 additions and 177 deletions.
  1. +31 −0 qrencode.php
  2. +184 −171 qrtools.php
  3. +77 −6 qrvect.php
View
@@ -299,6 +299,13 @@ public static function eps($text, $outfile = false, $level = QR_ECLEVEL_L, $size
$enc = QRencode::factory($level, $size, $margin);
return $enc->encodeEPS($text, $outfile, $saveandprint=false);
}
+
+ //----------------------------------------------------------------------
+ public static function svg($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
+ {
+ $enc = QRencode::factory($level, $size, $margin);
+ return $enc->encodeSVG($text, $outfile, $saveandprint=false);
+ }
//----------------------------------------------------------------------
public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
@@ -530,4 +537,28 @@ public function encodeEPS($intext, $outfile = false,$saveandprint=false)
}
}
+
+ //----------------------------------------------------------------------
+ public function encodeSVG($intext, $outfile = false,$saveandprint=false)
+ {
+ try {
+
+ ob_start();
+ $tab = $this->encode($intext);
+ $err = ob_get_contents();
+ ob_end_clean();
+
+ if ($err != '')
+ QRtools::log($outfile, $err);
+
+ $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
+
+ return QRvect::svg($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint);
+
+ } catch (Exception $e) {
+
+ QRtools::log($outfile, $e->getMessage());
+
+ }
+ }
}
Oops, something went wrong.

0 comments on commit 7632c7e

Please sign in to comment.