From e721fd3e094255b6bf69258100d7242b81735d86 Mon Sep 17 00:00:00 2001 From: Marco De Donno Date: Thu, 21 May 2020 23:00:32 +0200 Subject: [PATCH] Patch the calculation of the target resolution Since the image is streched in the svg, we need to take into account this ratio in the resolution calculation. --- js/backend.admin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/backend.admin.js b/js/backend.admin.js index 8df40ca..99222ba 100644 --- a/js/backend.admin.js +++ b/js/backend.admin.js @@ -1921,6 +1921,7 @@ Pianos4Backend.ImageManager = function( parent, params ) var suspected_resolution = parseInt( img.resolution ); var ruler_offset = 0; var ruler_mirror = false; + var img_ratio = null; var draw_ruler = function() { @@ -1943,6 +1944,7 @@ Pianos4Backend.ImageManager = function( parent, params ) $( "#gruler" ) .attr( "transform", "scale( " + suspected_resolution / 25.4 / ruler_size_px_per_mm + " ) translate( " + ruler_start_x + " " + ruler_start_y + " ) rotate( " + angle + " ) translate( " + ruler_offset + " -1 ) translate( 0 2 ) scale( 1 -1 )" ); } + console.log( suspected_resolution / img_ratio ); } } @@ -1953,7 +1955,7 @@ Pianos4Backend.ImageManager = function( parent, params ) var ratio_width = $( "#image_editor_img_svg > svg" ).width() / img.width; var ratio_height = $( "#image_editor_img_svg > svg" ).height() / img.height; - var ratio = Math.min( ratio_width, ratio_height ); + img_ratio = Math.min( ratio_width, ratio_height ); $( "#gruler" ) .on( "click", function( event ) -- GitLab