ACF Library

ResizeImage

Back to List

Description: Resize an image. Uses ImageMagic to resize high quality resizing

FileMaker Prototype:

Set Variable [$res; ACF_Run("ResizeImage"; string_path;  string_size)]

Category: UTILITY

Function source:

function ResizeImage ( string path, string size)
   // Requires plugin version 1.7.2.1 at least. 
   if ( path == "" ) then
      path = select_file ("Select a file to convert", desktop_directory());
   end if
   if ( path == "" ) then // User canceled
      return ""; 
   end if 
   string basepath = regex_replace("^(.+)/(.+\..+)$", path, "\1");
   string filename = regex_replace("^(.+)/(.+\..+)$", path, "\2");
   string filetype = regex_replace("^(.+/)(.+\.)(.+)$", path, "\3");
   string newfile = substitute(filename, "."+filetype, "") + "_"+size+"."+filetype;
   string commands = 
       format("convert %s -resize %s %s\n", filename, size, newfile) + 
       "identify " +newfile ; // Outputs image details
   string result = SystemCommand(commands, basepath);
   array string params; 
   params = explode (" ", trimboth(result)); 
   return basepath + "/" + params[1]; // New path / filename
end

The ResizeImage Function uses ImageMagic to resize an image. The function returns the path to the resized image in the same directory as the original. If the path parameter is empty, the function asks the user.

Requirements

  • Minimum plugin version: 1.7.2.1
  • ImageMagic command line utility must be installed on users computer. Open terminal, and type: convert --version to check.

Example

Set Variable [$res; ACF_Run("ResizeImage"; "~/Desktop/profile-picure.png";  "200")]
Back to List