sample #04
saving images contained in a frame
  1. <?php
  2. include("sample_utils.php"); // need to include this to use mk
  3.  
  4. $swfFN = "sample02.swf";
  5. $si = new MKswf_inspector($swfFN);
  6. $mt = $si->fetch_assoc();
  7. $fl = $si->get_frameList();
  8. $sca = new MKswf_serializer($mt, $fl);
  9. $im = new MKswf_item_grabber($swfFN, 1, IMAGE_ITEM);
  10. $bmList = $im->get_itemList();
  11. $str = "";
  12.  
  13. foreach($bmList as $bm){
  14. $imgFN = $bm->get_imageFileName();
  15. $bm->save_image();
  16. $sHtml = "<img src=\"" .$imgDir;
  17. $sHtml .= $imgFN ."\" width=\"";
  18. $sHtml .= $bm->get_imageWidth() ."\" height=\"";
  19. $sHtml .= $bm->get_imageHeight() ."\" />";
  20.  
  21. $str .= trace_var($sHtml, "saved image: " .$imgFN, false, false, true);
  22. }
  23.  
  24. $str .= trace_var(SERVER_MKTMP, "images saved, please look in", false, false, true);
  25. echo show_content($str, basename(__FILE__));
  26. ?>
saving images is quite easy, mk has to save some data before proceed, this is what MKswf_serializer does.
Note that lossy compressed images are saved as jpeg and losseless images as png.
Images are saved in tmp folder by default. mikrokosmos