From 79c89cf7ec52ba1909e1f8be6255c95394ede6fb Mon Sep 17 00:00:00 2001 From: James Shiffer Date: Mon, 21 Sep 2020 11:27:32 -0700 Subject: [PATCH] graphicsmagick coming soon --- README.md | 2 + util/GraphicsMagick.cfm | 240 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 util/GraphicsMagick.cfm diff --git a/README.md b/README.md index a718f5a..d9310ce 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ - Web server (recommended: IIS 5.0) +- GraphicsMagick (for automatic dithering) + - A computer from 2001, preferably running 32-bit XP ## Browser Compatibility diff --git a/util/GraphicsMagick.cfm b/util/GraphicsMagick.cfm new file mode 100644 index 0000000..14fba55 --- /dev/null +++ b/util/GraphicsMagick.cfm @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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 = []; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +