SWF To Image library - converting SWF flash movies into BMP, JPG, PNG image files from ColdFusion - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

SWF To Image library – converting SWF flash movies into BMP, JPG, PNG image files from ColdFusion

  • Home
  • /
  • Articles
  • /
  • SWF To Image library – converting SWF flash movies into BMP, JPG, PNG image files from ColdFusion

 

This example demonstrates how to use SWF To Image from ColdFusion script and convert SWF into JPEG image
Thanks to Aaron D. Neff – What iT iS dESign studios (www.itisdesign.com) for contributing this sample

Adobe ColdFusion example, using CFScript syntax (SWFToImage_CFScriptSyntax.cfm):

<!—
Filename: SWFToImage_CFScriptSyntax.cfm (Adobe ColdFusion example, using CFScript syntax, for Bytescout.com’s SWFToImage ActiveX/NET library)
Author: Aaron D. Neff – What iT iS dESign studios
Contact: www.itisdesign.com
Copyright: 2007 What iT iS dESign studios
Created: October 12th, 2007 (ver. 1.0)
Purpose: An example for creating an image (.bmp, .jpg, or .gif) from a swf file
Please Note: The SWFToImage.DLL COM object must first be registered with Windows, per these instructions: http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/. Basically, if you save the .dll to c:dllsSWFToImage.DLL, then you must run the following command from the DOS Command Prompt: regsvr32 c:dllsSWFToImage.DLL
—>
<!— Set path to existing SWF & location to save image —>
<!— Note: this example assumes the URL to the existing .swf file is www.domain.com/assets/swfs/myswf.swf —>
<!— Note: this example assumes the URL to save the image file is www.domain.com/assets/images/myimage.jpg —>
<cfscript>
imageWidth = 775; //default is 320
imageHeight = 150; //default is 320
rootPathToSWF = “/assets/swfs/myswf.swf”; //absolute path, from wwwroot, to swf
rootPathToIMG = “/assets/images/myimage.jpg”; //absolute path, from wwwroot, to save image
filePathToSWF = expandPath(rootPathToSWF); //automatically creates full system path by expanding absolute path
filePathToIMG = expandPath(rootPathToIMG); //automatically creates full system path by expanding absolute path
</cfscript>
<!— Create JPG —>
<cfscript>
SWFToImage = createObject(“com”, “SWFToImage.SWFToImageObject”);
SWFToImage.InitLibrary(“demo”, “demo”);
SWFToImage.InputSWFFileName = filePathToSWF;
SWFToImage.ImageOutputType = 1; //(0=.bmp, 1=.jpg, 2=.gif)
SWFToImage.ImageWidth = imageWidth;
SWFToImage.ImageHeight = imageHeight;
SWFToImage.Execute();
SWFToImage.SaveToFile(filePathToIMG);
</cfscript>
<!— Display Image —>
<cfoutput><img src=”#rootPathToIMG#” /></cfoutput>

Adobe ColdFusion example, using tag syntax (SWFToImage_TagSyntax.cfm):

<!—
Filename: SWFToImage_TagSyntax.cfm (Adobe ColdFusion example, using tag syntax, for Bytescout.com’s SWFToImage ActiveX/NET library)
Author: Aaron D. Neff – What iT iS dESign studios
Contact: www.itisdesign.com
Copyright: 2007 What iT iS dESign studios
Created: October 12th, 2007 (ver. 1.0)
Purpose: An example for creating an image (.bmp, .jpg, or .gif) from a swf file
Please Note: The SWFToImage.DLL COM object must first be registered with Windows, per these instructions: http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/. Basically, if you save the .dll to c:dllsSWFToImage.DLL, then you must run the following command from the DOS Command Prompt: regsvr32 c:dllsSWFToImage.DLL
—>
<!— Set path to existing SWF & location to save image —>
<!— Note: this example assumes the URL to the existing .swf file is www.domain.com/assets/swfs/myswf.swf —>
<!— Note: this example assumes the URL to save the image file is www.domain.com/assets/images/myimage.jpg —>
<cfset imageWidth = 775 /><!— default is 320 —>
<cfset imageHeight = 150 /><!— default is 320 —>
<cfset rootPathToSWF = “/assets/swfs/myswf.swf” /><!— absolute path, from wwwroot, to swf —>
<cfset rootPathToIMG = “/assets/images/myimage.jpg” /><!— absolute path, from wwwroot, to save image —>
<cfset filePathToSWF = expandPath(rootPathToSWF) /><!— automatically creates full system path by expanding absolute path —>
<cfset filePathToIMG = expandPath(rootPathToIMG) /><!— automatically creates full system path by expanding absolute path —>
<!— Create JPG —>
<cfobject action=”create” type=”com” name=”SWFToImage” class=”SWFToImage.SWFToImageObject” />
<cfset SWFToImage.InitLibrary(“demo”, “demo”) />
<cfset SWFToImage.InputSWFFileName = filePathToSWF />
<cfset SWFToImage.ImageOutputType = 1 /><!— (0=.bmp, 1=.jpg, 2=.gif) —>
<cfset SWFToImage.ImageWidth = imageWidth />
<cfset SWFToImage.ImageHeight = imageHeight />
<cfset SWFToImage.Execute() />
<cfset SWFToImage.SaveToFile(filePathToIMG) />
<!— Display Image —>
<cfoutput><img src=”#rootPathToIMG#” /></cfoutput>

Tutorials:

prev
next