diff --git a/includes/AnnotationHandler.php b/includes/AnnotationHandler.php index 0c8ce3e..45c05d2 100644 --- a/includes/AnnotationHandler.php +++ b/includes/AnnotationHandler.php @@ -87,9 +87,7 @@ class AnnotationHandler extends CodeContentHandler { */ private function buildSvg($metadata) { //Set SVG UID-ish for element IDs - $svgID = bin2hex(random_bytes(6)); - self::console_log($svgID, true); - self::console_log(wfRandomString(12), true); + $svgID = wfRandomString(12); //Check if the image to annotate has been set if (isset($metadata['baseImage'])) { @@ -101,17 +99,12 @@ class AnnotationHandler extends CodeContentHandler { //Gather basic data $elBaseImg = ''; - $vbHeight = 100; - $vbWidth = 100; if ($baseImage) { $imageStr = 'data:image/png;base64,' . base64_encode(file_get_contents($baseImage->getLocalRefPath())); $baseHeight = $baseImage->getHeight(); $baseWidth = $baseImage->getWidth(); $baseAspect = $baseHeight / $baseWidth; - $vbWidth = 100 / sqrt($baseAspect); $fixScale = $baseWidth / 100 * sqrt($baseAspect); - self::console_log($fixScale, true); - //$vbHeight = $baseAspect * $vbWidth; $attrBase = array( 'class' => 'annot-base', 'preserveAspectRatio' => 'none', @@ -213,8 +206,8 @@ class AnnotationHandler extends CodeContentHandler { } } $attrMaskRect = array( - 'width' => $vbWidth, - 'height' => $vbHeight, + 'width' => $baseWidth / $fixScale, + 'height' => $baseHeight / $fixScale, 'fill' => 'white' ); $maskRect = Html::rawElement('rect',$attrMaskRect); @@ -242,7 +235,6 @@ class AnnotationHandler extends CodeContentHandler { $tmpFileFactory = MediaWikiServices::getInstance()->getTempFSFileFactory(); $tmpFile = $tmpFileFactory->newTempFSFile( 'annotSvg_', 'svg' ); - //$tmpFile = TempFSFile::factory( $pageTitle, 'svg' ); if ( !$tmpFile ) { $status->fatal( 'svg-error-create-temp', 'Failed to create temp SVG' ); return;