Last active
March 18, 2022 18:47
-
-
Save JamoCA/d52eb99b462e42866694975eb9af1396 to your computer and use it in GitHub Desktop.
Convert HEIC to JPG (using ColdFusion & ImageMagick Mogrify) #cfml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 20200529 SunStar Media https://www.sunstarmedia.com/ | |
https://gist.github.com/JamoCA/d52eb99b462e42866694975eb9af1396 ---> | |
<cffunction name="convertHEIC" returntype="any" output="no" hint="Converts HEIC file to JPG"> | |
<cfargument name="filepath" type="string" required="true"> | |
<cfargument name="destination" type="string" default="jpg" required="true"> | |
<cfargument name="delete" type="boolean" default="false" required="true"> | |
<cfargument name="exePath" default="c:\cfusionextra\ImageMagick\mogrify.exe" type="string" required="false"> | |
<cfargument name="useCfxExec" default="0" type="string" required="false"> | |
<cfset var temp = ["raw":"", "success":false, "defaults":arguments]> | |
<cfif not len(arguments.exePath)> | |
<cfset arguments.exePath = "c:\cfusionextra\ImageMagick\mogrify.exe"> | |
</cfif> | |
<cfif fileExists(arguments.filepath)> | |
<cfif val(arguments.useCfxExec)> | |
<cfx_exec cmd="#arguments.exePath# -format jpg ""#arguments.destination#"" ""#arguments.filepath#""" name="temp.raw" timeout="10000"> | |
<cfelse> | |
<cfexecute name="#arguments.exePath#" arguments="-format jpg ""#arguments.destination#"" ""#arguments.filepath#""" variable="temp.raw" timeout="10"></cfexecute> | |
</cfif> | |
</cfif> | |
<cfset temp.success = fileExists(arguments.destination)> | |
<cfif temp.success and arguments.delete> | |
<cftry> | |
<cfset fileDelete(arguments.filePath)> | |
<cfcatch></cfcatch> | |
</cftry> | |
</cfif> | |
<cfreturn temp> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment