if (Attributes.Action IS "Commands"){ /* Nothing */ } else if (NOT Find("*", Attributes.InFile) AND NOT FileExists(Attributes.InFile)){ throw(message="GraphicsMagick: InFile image does not exist."); } if (NOT listFindnocase(AllowedActions, Attributes.Action)){ throw(message="GraphicsMagick: Invalid action."); } if (NOT LEN(Attributes.OutFile)){ Attributes.OutFile = Attributes.InFile; } if (NOT IsNumeric(Attributes.Quality) OR VAL(Attributes.Quality) LT 1 OR VAL(Attributes.Quality) GT 100){ Attributes.Quality = 75; } TempDebug = {"debug"="", "width"=0, "height"=0, "commandline"="", "duration"=0, "attributes"=TempAttributes}; Caller[trim(Attributes.Result)] = TempDebug; CommandLine = ["Convert", "-colorspace #Attributes.ColorSpace#", "-strip" ]; if (val(Attributes.depth)){ ArrayAppend(CommandLine, "-depth #VAL(Attributes.depth)#"); } if (isBoolean(Attributes.Minify) AND YesNoFormat(Attributes.Minify)){ ArrayAppend(CommandLine, "-minify"); } if (isBoolean(Attributes.monochrome) AND YesNoFormat(Attributes.monochrome)){ ArrayAppend(CommandLine, "-monochrome"); } if (val(Attributes.Paint)){ ArrayAppend(CommandLine, "-paint #VAL(Attributes.Paint)#"); } if (val(Attributes.Colors)){ ArrayAppend(CommandLine, "-colors #VAL(Attributes.Colors)#"); } if (LEN(Attributes.Filter)){ ArrayAppend(CommandLine, "-filter #Attributes.Filter#"); } if (isBoolean(Attributes.AutoOrient) AND YesNoFormat(Attributes.AutoOrient)){ ArrayAppend(CommandLine, "-auto-orient"); } else if (ListFindNocase("TopLeft,TopRight,BottomRight,BottomLeft,LeftTop,RightTop,RightBottom,LeftBottom,Top-Left,Top-Right,Bottom-Right,Bottom-Left,Left-Top,Right-Top,Right-Bottom,Left-Bottom", Attributes.Orient)){ ArrayAppend(CommandLine, "-orient #Attributes.Orient#"); } if (LEN(Attributes.Rotate)){ ArrayAppend(CommandLine, "-rotate #Attributes.Filter#"); } if (LEN(Attributes.Density)){ ArrayAppend(CommandLine, "-density #Attributes.Density#"); } if (Listfindnocase("None,BZip,Fax,Group4,JPEG,Lossless,LZW,RLE,Zip,LZMA", Attributes.Compress)){ ArrayAppend(CommandLine, "-compress #Attributes.compress#"); } if (isBoolean(Attributes.Dither) AND YesNoFormat(Attributes.Dither)){ ArrayAppend(CommandLine, "-dither"); } if (Attributes.Action IS "AspectCrop"){ ArrayAppend(CommandLine, "-size #VAL(Attributes.width)#x#VAL(Attributes.Height)#"); } ArrayAppend(CommandLine, """#Attributes.InFile#"""); /* Action functions */ if (Attributes.Action IS "AspectCrop"){ ArrayAppend(CommandLine, "-thumbnail ""#VAL(Attributes.width)#x#VAL(Attributes.Height)#^"""); ArrayAppend(CommandLine, "-gravity #Attributes.Gravity#"); ArrayAppend(CommandLine, "-extent #VAL(Attributes.width)#x#VAL(Attributes.Height)#"); } else if (Attributes.Action IS "resizeWidth"){ ArrayAppend(CommandLine, "-resize ""#VAL(Attributes.width)#x-1"""); } else if (Attributes.Action IS "resizeHeight"){ ArrayAppend(CommandLine, "-resize ""x#VAL(Attributes.height)#"""); } else if (Attributes.Action IS "resizeFit"){ ArrayAppend(CommandLine, "-resize ""#VAL(Attributes.width)#x#VAL(Attributes.height)#>"""); } else if (Attributes.Action IS "Crop" AND VAL(Attributes.CropX) AND VAL(Attributes.CropY)){ ArrayAppend(CommandLine, "-crop ""#VAL(Attributes.Width)#x#VAL(Attributes.Height)#+#VAL(Attributes.CropX)#+#VAL(Attributes.CropY)#"""); } if (isBoolean(Attributes.UseUnsharp) AND YesNoFormat(Attributes.UseUnsharp)){ ArrayAppend(CommandLine, "-unsharp 0.25x0.25+8+0.065"); } ArrayAppend(CommandLine, "-interlace #Attributes.Interlace#"); ArrayAppend(CommandLine, "-quality #VAL(Attributes.Quality)#"); ArrayAppend(CommandLine, "+profile ""*"""); if (LEN(TRIM(Attributes.Comment))){ ArrayAppend(CommandLine, "-comment ""#TRIM(Attributes.Comment)#"""); } ArrayAppend(CommandLine, """#Attributes.OutFile#"""); /* If Identify, clear commands */ if (Attributes.Action IS "identify"){ CommandLine = []; }