diff --git a/htdocs/product/photos_resize.php b/htdocs/core/photos_resize.php similarity index 62% rename from htdocs/product/photos_resize.php rename to htdocs/core/photos_resize.php index 68d6e8d7382..aacd0c548b7 100644 --- a/htdocs/product/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -34,7 +34,7 @@ if (isset($_GET["id"])) $result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid); -$original_file = isset($_GET["file"])?urldecode($_GET["file"]):''; +$original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):''; $langs->load("products"); @@ -46,32 +46,28 @@ if (!$user->rights->produit->lire) accessforbidden(); * Actions */ -if ($_POST["action"] == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") &&(isset($_POST["sizey"]) != "")) +if ($_POST["action"] == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) { -/* $thumb = new Imagick($conf->produit->dir_output."/".$_POST["file"]); - $height=$thumb->getImageHeight(); // dimensions de l'image actuelle - $width=$thumb->getImageWidth(); // dimensions de l'image actuelle + $fullpath=$conf->produit->dir_output."/".$_POST["file"]; + $result=dol_imageResize($fullpath,$_POST['sizex'],$_POST['sizey']); - if($_POST["sizex"] != "") + if ($result == $fullpath) { - if ($width > $_POST['sizex']) - $thumb->scaleImage(intval($_POST['sizex']), 0); + header("Location: ".DOL_URL_ROOT."/product/photos.php?id=".$_POST["product"].'&action=addthumb&file='.urldecode($_POST["file"])); + exit; } - if($_POST["sizey"] != "") + else { - if ($height > $_POST['sizey']) - $thumb->scaleImage(0, intval($_POST['sizey'])); + $mesg=$result; + $_GET['file']=$_POST["file"]; + $_GET['id']=$_POST["id"]; } - $thumb->writeImage($conf->produit->dir_output."/".$_POST["file"]); - $thumb->destroy(); -*/ - header("Location: ".DOL_URL_ROOT."/product/photos.php?id=".$_POST["product"].'&action=addthumb&file='.urldecode($_POST["file"])); - exit; } // Crop d'une image if ($_POST["action"] == 'confirm_crop' && $_POST["file"]) { + // TODO Add function to crop image in images.lib.php /* $thumb = new Imagick($conf->produit->dir_output."/".urldecode($_POST["file"])); $thumb->cropImage($_POST['w'], $_POST['h'], $_POST['x'], $_POST['y']); $thumb->writeImage($conf->produit->dir_output."/".urldecode($_POST["file"])); @@ -86,31 +82,35 @@ if ($_POST["action"] == 'confirm_crop' && $_POST["file"]) * View */ -llxHeader($head, $langs->trans("Resize"), '', '', 0, 0, array('includes/jcrop/js/jquery.min.js','includes/jcrop/js/jquery.Jcrop.min.js','lib/lib_photosresize.js'), array(DOL_URL_ROOT.'/includes/jcrop/css/jquery.Jcrop.css')); +llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('includes/jcrop/js/jquery.min.js','includes/jcrop/js/jquery.Jcrop.min.js','lib/lib_photosresize.js'), array(DOL_URL_ROOT.'/includes/jcrop/css/jquery.Jcrop.css')); -print_fiche_titre($langs->trans("Current")); +print_fiche_titre($langs->trans("Image")); + +if ($mesg) print '