How 2 import vector from ANY .SWF FLASH FILE to InkScape/SVG

Using Inkscape with other software? Talk about it here.
Nerd42
Posts: 3
Joined: Wed Sep 09, 2009 5:02 am

How 2 import vector from ANY .SWF FLASH FILE to InkScape/SVG

Postby Nerd42 » Wed Sep 09, 2009 5:35 am

Who this guide is written for:
For n00bs who already know how to save files: This guide is for you!! :)

If you don't know what a n00b is, but already know how to save files: This guide is for you!! :)

For non-n00bs: This is a guide on how to do this with Windows using proprietary software packages, not how to take everything apart in Linux with Gnash, if that's even possible. Richard Stallman would not like this method but who cares what he says as long as I get my art done. :p

Programs needed:
* Windows
* Web browser (I recommend FireFox)
* Sothink SWF Decompiler YOU MUST HAVE THE FULL VERSION 99% OF THE TIME. (I have version 3. Not sure if the new version works the same, but version 3 definitely works)
* Macromedia Flash MX 2004. (Newer versions of Flash WILL NOT WORK, due to stupid dishonest practices of Adobe, Inc, see rant below. Some older versions might.)
* If working with a .SWF or .FLA file that won't decompile into MX 2004 format, whatever newer version of Flash it uses will be required in addition to MX 2004.
* GPL GhostScript and GSView (Free!)
* InkScape, obviously.

I will say nothing about how to get these programs ... except that um ... not everybody gets all of them legally and since we're dealing with Adobe's anti-consumer practices here ... if you have to pirate old versions of Flash in order to get this done, I, personally, don't see a moral problem with that. I'm just not going to help you do it. You're on your own with getting the above software.

Instructions:
1. Open the web page containing the Flash file which has your desired vector art in it.
2. Find the "View Source" option in the browser. A window should open having the code that makes the page work in it.
3. Search the code for ".swf". Somewhere in there, if the page contains Flash content, there should be a URL to the location of the .swf file on the server. Put that URL in your address bar and the Flash file should open full screen in the browser. Goto the menu "File > Save page as..." on most browsers to save that .swf file to your hard disk. If you don't know how to save files, go learn how to use computers and then come back to this problem later.
4. Open your .SWF file in Sothink SWF Decompiler and find the resources you want in it's resource tree. If you can't find them, you probably have the wrong .SWF file. Uncheck everything else and check just the things you want. (This makes them easier to find later) Then export to .FLA format. If given a choice, make sure your .FLA version is Macromedia Flash MX 2004.
5. If you can't get Sothink SWF Decompiler to save in MX 2004 format, you may need to save in a newer Flash format. In that case, open the .FLA file in the new version of Flash and save in MX 2004 format from there. (If you are reading this sometime in the future when Adobe has taken out the MX 2004 format entirely in order to prevent people from getting vector art out of new versions of Flash, save down as far as you can and open that in the older version of Flash ... work your way down until you get to MX 2004)
6. Open your .FLA file in Macromedia Flash MX 2004. If it doesn't open, something went wrong in step 4. Select the items you want to use in InkScape and goto the menu, "File > Export..." Export as .EPS (PostScript)
7. Open your .EPS file in GSView (the graphical front end for GhostScript) You should see the art you want. Goto the menu: "File > Convert..." and a dialog box should come up. You want the device "pdfwrite" and (probably) resolution 720. Hit "OK" and a file saving dialog box should come up. You are saving your file as a .PDF document. If you don't know how to save files, see step 3.
8. Open the resulting .PDF file in InkScape! Your art should appear! You usually have to "Ungroup" twice to be able to move stuff around. You can now save in .SVG format.

Try it with stuff from Homestar Runner!

Rant:
Macromedia Flash MX 2004 had perfectly good export features to other vector graphics editors. Then Adobe bought out the company. They have sabotaged later/newer versions of Flash to not have these features. Flash CS4 only exports vector graphics in the secret/proprietary .ai format in order to require people to pay hundreds of dollars for a program they don't need: Adobe Illustrator. As you can see from the above method, having Flash MX 2004 and InkScape makes Illustrator unnecessary for most uses of vector graphics coming out of Flash.

Adobe, Inc. wrote:"Adobe has taken a leadership role in the development of the SVG specification and continues to ensure that its authoring tools are SVG compatible."
Source: http://www.adobe.com/svg/
LIE!!

Adobe products may import SVG but they are NOT "SVG compatible." If they were, you would not need the above instructions. Adobe won't let you export to .SVG because they're afraid that people might have the freedom and choice to use other vector graphics editors such as InkScape instead of Illustrator and thus avoid paying them hundreds of dollars for a DRM-locked product which they often steal right back from you. If your computer crashes, leaving you no way to "deactivate" your software so you can "activate" it again, they'll just tell you to buy it again, (that your product license has expired and you need to buy another license) paying them hundreds of dollars more. This is stealing from you the whole value of what you initially paid for.

If you buy Illustrator and run into this problem, they are basically taking your money, locking you out of the program you bought and then demanding more money just to get your own work back. Your art, saved in their ".ai" format, can only open with their program. This is basically holding your art up for ransom. Out of all the words I can think of to describe this behavior of Adobe, the words "stealing" and "piracy" seem to describe it best. For you to pirate an Adobe product would seem to be the exact same type of behavior in a moral sense as they exhibit toward their legitimate paying customers.

For more information about DRM (Digital Restrictions Management) and why it's evil, see http://www.defectivebydesign.org/
Last edited by Nerd42 on Fri Dec 24, 2010 12:56 pm, edited 3 times in total.

hadi

Re: How 2 import vector from ANY .SWF FLASH FILE to InkScape/SVG

Postby hadi » Wed Nov 03, 2010 4:38 pm

This Bash Script extracts SWF objects to an SVG file:

Requiremens:
    swftools

Code: Select all

#!/bin/bash

#USAGE ./swf2svg.sh /path/to/file.swf > output.svg

FILE=$1;
DUMP="dump.txt"

echo '<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">

';

swfdump -s $FILE > $DUMP

fillCols=();
lineCols=();
lineWidth=();

FILLREGEX="[0-9]+(\s*)SOLID [0-f]{8}";
LINEREGEX="[0-9]+(\s*)[0-9]\.[0-9]{0,2} [0-f]{8}";

lastStartPoint="";
pathClosedTag="";
firstGroup="TRUE";
firstPath="TRUE";

cat $DUMP | while read line
do
   #Remove ( and )
   line=`echo $line | sed "s/[()]//g"`
   
   #tmp=`echo $line | egrep -o "DEFINE(SHAPE|SPRITE)"`;
   tmp=`echo $line | egrep -o "DEFINE(SHAPE|SPRITE)[0-9]? defines id [0-9]+"`;
   
   if [ "$tmp" !=  "" ]
   then
      if [ "$firstGroup" == "TRUE" ]
      then
         firstGroup="FALSE";
      else
         if [ "$firstPath" == "FALSE" ]
         then
            if [ "$lastStartPoint" != "" ]
            then
               if [ "$lastStartPoint" == "$curPoint" ]
               then
                  pathClosedTag="Z";
               fi
            fi
      
            lastStartPoint=$curPoint;
            echo $pathClosedTag'" />';
         fi;
         firstPath="TRUE";
         echo '</g>';
      fi
      
      id=`echo $tmp | awk {'print $4'}`
      
      echo '<g id="'$id'">';
      fillCols=();
      lineCols=();
      lineWidth=();
   fi
   
   tmp=`echo $line | egrep -o  "($FILLREGEX)?((\s*)$LINEREGEX)?"`;
   if [ "$tmp" !=  "" ]
   then
      fillInx=`echo $tmp | egrep -o  "$FILLREGEX" | awk {'print $1'}`;
      fillCol=`echo $tmp | egrep -o  "$FILLREGEX" | awk {'print $3'}`;
            
      if [ "$fillCol" != "" ]
      then
         fillCols[$fillInx]=$fillCol;
      fi
      
      lineInx=`echo $tmp | egrep -o  "$LINEREGEX" | awk {'print $1'}`;
      lineWth=`echo $tmp | egrep -o  "$LINEREGEX" | awk {'print $2'}`;
      lineCol=`echo $tmp | egrep -o  "$LINEREGEX" | awk {'print $3'}`;
      if [ "$lineCol" != "" ]
      then
         lineCols[$lineInx]=$lineCol;
         lineWidth[$lineInx]=$lineWth;
      fi
   fi
   
   tmp=`echo $line | awk {'print $6'}`;
   
   if [ "$tmp" ==  "lineTo" ]
   then
      echo $line | awk {'print "L"$7" "$8'}
   fi
   
   if [ "$tmp" ==  "moveTo" ]
   then
   
      curPoint=`echo $line | awk {'print $9" "$10'}`;
   
      if [ "$lastStartPoint" != "" ]
      then
         if [ "$lastStartPoint" == "$curPoint" ]
         then
            pathClosedTag="Z";
         fi
      fi
      
      lastStartPoint=$curPoint;
      
      if [ "$firstPath" == "TRUE" ]
      then
         firstPath="FALSE";
      else
         echo $pathClosedTag'" />';
      fi;
      
      #Remove : and /
      line=`echo $line | sed "s/[:/]/ /g"`
      
      fInx=`echo $line | awk '{printf "%d", $4}'`;
      lInx=`echo $line | awk '{printf "%d", $6}'`;
      
      stl="";
      val=${fillCols[$fInx]:0:6};
      if [ $fInx -gt 0 -a "$val" != "" ]
      then
         stl="fill:#$val;";
      fi
      
      val=${lineCols[$lInx]:0:6};
      if [ $lInx -gt 0 -a "$val" != "" ]
      then
         stl=$stl"stroke:#$val;";
         
         val=${lineWidth[$lInx]};
         if [ "$val" != "" ]
         then
            stl=$stl"stroke-width:$val;";
         
         fi
      fi
      
      echo '<path style="'$stl'" d="';
      echo $line | awk {'print "M"$9" "$10'}
   fi
   
   if [ "$tmp" ==  "splineTo" ]
   then
      echo $line | awk {'print "Q"$7" "$8" "$9" "$10'}
   fi
   
done
echo 'Z" />';
echo '</g>';
echo '</svg>';


Sayed Hadi Rastgou Haghi

KBX

Re: How 2 import vector from ANY .SWF FLASH FILE to InkScape

Postby KBX » Fri Dec 24, 2010 4:25 am

Hi,
Noob here, can you plz tell me how to use the Bash Script you mentioned? I have downloaded swftools. Errr...now what?

I want to convert a web page flash animation into useable svg or .ai file

Best Regards,
Karan


Return to “Inkscape & other”