1 Reply Latest reply on Aug 10, 2016 8:01 PM by Laubender

    [jsx] center specific part of image by resizing / moving

    sstrs

      Dear internet,

       

      i'm trying to center a specific part of an image (a face, detected by opencv) inside a frame. the face should have a fixed size.

      the image has the following information:

       

      var img = {
           width: XYZ,
           height: XYZ,
           face: {
                width: XYZ,
                height: XYZ,
                x: XYZ,
                y: XYZ 
                }
           }
      

       

      (everything in pixels).

      how would you do this?

      i was thinking about placing the image at 100%, moving it to the left and top to center the center of the face inside the frame and finally resizing it to have a certain width, but there has to be a simpler way?!

       

      Thank you!

        • 1. Re: [jsx] center specific part of image by resizing / moving
          Laubender Adobe Community Professional & MVP

          You could find out the size of a placed image (its pixel dimensions) on the page by reading out the value of the property effectivePpi. That will give you an array of two numbers. The effective PPI (pixels per inch) of the width and the height of the image. From that you can correlate the actual meassurement unit with the area in pixels you are interested.

           

          Both values of effectivePpi are the same, if the aspect ratio of the placed image is maintained.
          They can differ, if the image is stretched or squeezed.

           

          Regards,
          Uwe

          1 person found this helpful