Importazione immagini

samuelson

Nuovo Utente
3 Mar 2020
4
0
1
Buongiorno a tutti,
il vecchio "informatico" che ormai si è licenziato ha lasciato in sospeso questo progetto:

[edit mod - no link]

Si avvia con XAMPP in localhost, con servizio apache attivo.

Il problema è che quando si importa l'immagine per la modifica, mi piacerebbe che le foto venissero automaticamente ridimensionate con altezza e larghezza indicate da me e bloccate.


Grazie
 
Ultima modifica di un moderatore:
Ci provo:

JavaScript:
 var updateImageWatermarks = function(watermark) {
      if ($scope.activeWatermark && $scope.activeWatermark.linked) {
        var imgHeight = $scope.activeImage.height;
        var imgWidth = $scope.activeImage.width;
        var percentTop = watermark.get("top") / imgHeight;
        var percentLeft = watermark.get("left") / imgWidth;

        var activeScale = $scope.activeImage.scale;

        var scaleX = watermark.get("scaleX");
        var scaleY = watermark.get("scaleY");
        var angle = watermark.get("angle");
        var opacity = watermark.get("opacity");
        $scope.current.opacity = opacity;

        var color, fontSize, fontFamily, text, backgroundColor;

        if (watermark.type == "text") {
          color = watermark.get("fontColor");
          $scope.current.fontColor = color;

          backgroundColor = watermark.get("backgroundColor");
          $scope.current.backgroundColor = backgroundColor;

          fontSize = watermark.get("fontSize");
          $scope.current.fontSize = fontSize;

          fontFamily = watermark.get("fontFamily");
          text = watermark.get("text");
        }

        $scope.images.forEach(function(image) {
          if (image != $scope.activeImage) {
            var objects = image.fabric.getObjects();
            var target = objects.find(function(wm) {
              return wm.wmid == watermark.wmid;
            });
            if (target && target.linked) {
              var targetWmTop = image.height * percentTop;
              var targetWmLeft = image.width * percentLeft;
              target.set("top", targetWmTop);
              target.set("left", targetWmLeft);
              target.set("scaleX", scaleX * (1 / image.scale) * activeScale);
              target.set("scaleY", scaleY * (1 / image.scale) * activeScale);
              target.set("angle", angle);
              target.set("opacity", opacity);

              if (target.type == "text") {
                target.setColor(color);
                target.set("fontSize", fontSize);
                target.set("fontFamily", fontFamily);
                target.set("backgroundColor", backgroundColor);
                target.set("text", text);
              }

              target.setCoords();
            }
          }
        });
      }
    };
 

Discussioni simili