5 Replies Latest reply on Aug 22, 2016 9:34 PM by user19752

    Scaling images to 640 width

    Tom_Droz

      FM14 Windows

       

      I have container fields that I want to have the images inserted always be resized to 640 pixels wide.

       

      so if the original is smaller 600x400  I would want it to be converted to 640x426.66

       

      I have a FM solution that will consistently create the thumbnail if they are larger than 640.

       

      I have attempted this with MBS and had multiple emails with Christian including sending him the file.   His reply was it is working, the output says otherwise.   I am swearing off MBS.  So any other solution out there for this?

       

      thanks!

       

      Tom

        • 1. Re: Scaling images to 640 width
          monkeybreadsoftware

          It would be like this:

           

          Set Variable [$Image; Value:MBS("GMImage.NewFromContainer"; Image Scaling::InputImage)]

          Set Variable [$r; Value:MBS("GMImage.Scale"; $Image; "640x480")]

          Set Field [Image Scaling::Result; MBS("GMImage.WriteToPNGContainer"; $Image)]

          Set Variable [$r; Value: MBS("GMImage.Destroy"; $Image)]

           

          This does the scale. If you also want to remove metadata, you can do:

           

          Set Variable [$Result; Value:MBS( "GMImage.SetProfile"; $image; "XMP"; "" )]

          Set Variable [$Result; Value:MBS( "GMImage.SetProfile"; $image; "EXIF"; "" )]

          Set Variable [$Result; Value:MBS( "GMImage.SetProfile"; $image; "IPTC"; "" )]

          • 2. Re: Scaling images to 640 width
            Tom_Droz

            why would it say 640x480?

             

            if the original is 600x400 what would the output be?

             

            I sent you the file and your reply was "The
            picture is broken, so the output is as wrong as the input.
            "

             

            I pointed out I have seen this happen 100's of time on many different customers and that the photo was resized in Photoshop, so the "The picture is broken, so the output is as wrong as the input."  is a non helpful answer

            • 3. Re: Scaling images to 640 width
              monkeybreadsoftware

              A 600x400 picture would be upscaled to 640x480.

               

              The picture you had was 800x1600 and in the header stated it was 640x480 and those sizes don't match. Such an image file should not exist. Probably it was created by mistake.

              • 4. Re: Scaling images to 640 width
                Tom_Droz

                It was not created by mistake, the actual size is 800x1600

                if you ask FM to Give the size it reports:

                 

                You continue to give a solution that dosent work

                • 5. Re: Scaling images to 640 width
                  user19752

                  Here is a vbscript. You can use it with script as

                  export field contents

                  send event

                  insert picture

                   

                  If you use BaseElements plug-in, the steps can be in a calculation.

                   

                  Set Img = CreateObject("WIA.ImageFile")

                  Set IP = CreateObject("WIA.ImageProcess")

                  Set fso = CreateObject("Scripting.FileSystemObject")

                  Set argv = WScript.Arguments

                  Img.LoadFile(argv(0))

                  IP.Filters.Add(IP.FilterInfos("Scale").FilterID)

                  'Resize to width 640

                  IP.Filters(1).Properties("MaximumWidth") = 640

                  IP.Filters(1).Properties("MaximumHeight") = Img.Height * 640 / Img.Width + 1

                  Set Img = IP.Apply(Img)

                  fso.DeleteFile(argv(0))

                  Img.SaveFile(argv(0))