3 Replies Latest reply on Jun 7, 2008 6:32 AM by Greg Dove

    resize a photo based on two points and its distance

    konach
      Is it difficult to do it?

      Assume the frame showing the photo to be 600X600 pixels
      When the user uploads a photo:
      1: he enter a value D (for example, D=7)
      2: He then point out two points (pt.A & pt.B)
      Assume the bottom left corner to be (0,0)
      3:The program then resize and rotate the photo such that,
      y-coordinate for both pt.A and pt.B to be 400 pixel
      x-coordinate for pt.A=300-8D=244 pixel
      x-coordinate for pt.B=300+8D=356 pixel
      4: The part outside the frame will be cut, and the image size becomes 600x600 pixels
      5: Save the photo

      Is it difficult to do so?

      Thank you
        • 1. Re: resize a photo based on two points and its distance
          Greg Dove Level 4
          Yes, you can do that type of thing with some Math and use of the Matrix class.

          You would use a mask to help with the clipping I'd assume. Perhaps that will be needed inside your frame in some situations, to provide vertical and horizontal edges to the transformed image inside the frame.

          Saving an image is possible in as2, but as3 makes it a lot easier/more efficient (it still has to go via the server before it can be saved locally if that is required - FP10 will change this in the future, but that is also as3).
          The reference that is often quoted here for saving images from as2 is the BitmapExporter class by Mario Klingemann, so you may want to google that.
          • 2. Re: resize a photo based on two points and its distance
            konach Level 1
            quote:

            Originally posted by: GWD
            Yes, you can do that type of thing with some Math and use of the Matrix class.

            You would use a mask to help with the clipping I'd assume. Perhaps that will be needed inside your frame in some situations, to provide vertical and horizontal edges to the transformed image inside the frame.

            Saving an image is possible in as2, but as3 makes it a lot easier/more efficient (it still has to go via the server before it can be saved locally if that is required - FP10 will change this in the future, but that is also as3).
            The reference that is often quoted here for saving images from as2 is the BitmapExporter class by Mario Klingemann, so you may want to google that.


            Thank you

            Is that mean it is possible to do it easier by making use of AS3?

            Actually this is one of the modules in my PHP program, I have to integrate it into php script.

            • 3. Re: resize a photo based on two points and its distance
              Greg Dove Level 4
              With as3, its the saving part that might be easier or more efficient. The other part will be the same or similar amount of work.
              With as3 it is possible to easily encode the image as a regular jpeg or png format from the BitmapData and upload the already encoded image. There are classes available to do this in as3.
              In as2 you need to upload the image in another encoded format because you cannot use raw binary data for uploading. I think the most frequently used method is base64 encoding, but I have heard of other approaches as well, and some have been posted in this forum in the past. I can't remember what the BitmapExporter class uses.