Open rafik73github opened 4 years ago
Welcome Is it possible to change the DPI for JPG? For now I have to deal in the following way, but it slows down work, because the image must be sent to the server to change DPI in PHP.
JS:
var pdf = $('#pdf_area > .ol-viewport')[0]; domtoimage.toJpeg(pdf, { quality : 1 } ) .then(function (dataUrl) { // alert(dataUrl); //######################################################## $.ajax({ // ajax type : "POST", url : "dpi_change.php", data : { ajax_dataUrl : dataUrl, ajax_pdf_zoom_terrain_number : pdf_zoom_terrain_number } , context: this, success : function(callback) { var link = document.createElement('a'); link.download = 'Teren_numer_' + pdf_zoom_terrain_number +'.jpg'; link.href = callback; link.click(); } //success }); //ajax
PHP:
$ajax_dataUrl = isset($_POST['ajax_dataUrl']) ? $_POST['ajax_dataUrl'] : ''; $ajax_pdf_zoom_terrain_number = isset($_POST['ajax_pdf_zoom_terrain_number']) ? $_POST['ajax_pdf_zoom_terrain_number'] : ''; $path = $ajax_dataUrl; $del_string = 'data:image/jpeg;base64,'; $path = str_replace($del_string, "", $path); $path = base64_decode($path); $image = substr_replace($path, pack("cnn", 1, 180, 180), 13, 5); $enc = base64_encode($image); $callback = $del_string.$enc; echo $callback;
Welcome Is it possible to change the DPI for JPG? For now I have to deal in the following way, but it slows down work, because the image must be sent to the server to change DPI in PHP.
JS:
PHP: