[swf2img]SWFファイルをイメージファイルに変換する(といってもキャプチャー撮るだけ)
前提にFlashが無い事がありますが
先に記事にした
[swf2pdf]SWFファイルをPDFに変換する(といってもPDFに印刷する感じ)
だと
どうしても
上手くPDFにならない場合があるので
キャプチャー撮る事でイメージに変換する事にしました。
【前提】swfのサイズが縦型のみ(フルスクリーンにした時に高さが画面100%になるような物)
中身を見るだけなら
Adobe Bridge で確認出来ますが
イメージファイルが必要になったので作りました。
1:ファイルを開く
2:フルスクリーンにする
3:キャプチャーを撮る
4:トリミングする
の
4ステップ
Flash Player archives 版が必要です
----------------------------------------------ドロップの始まり
on open DropObj
-----------------------------------------------必要なアプリケーションを起動しておく
tell application "Flash Player"
launch
activate
end tell
tell application "System Events"
launch
activate
end tell
tell application "Image Events"
launch
activate
end tell
tell application "Finder"
------------------------------------------------繰り返しの始まり
repeat with ObjFiles in DropObj
--------------------------------------------------ファイル名を取得
set theName to name of ObjFiles
------------------------------------------------パスを取得
set theAlias to ObjFiles as alias
------------------------------------------------Flash Playerを起動
tell application "Flash Player"
activate
------------------------------------------------まずは普通にファイルを開く
open theAlias
------------------------------------------------開くのを待つ意味の、おまじないの1秒
delay 1
tell window 1
activate
------------------------------------------------普通に開いた時のサイズをリストで受け取り
set theOrgBounds to bounds as list
------------------------------------------------ファイルバーの分
set theOrgBar to item 2 of theOrgBounds as number
------------------------------------------------幅
set theOrgW to item 3 of theOrgBounds as number
------------------------------------------------高さ
set theOrgH to item 4 of theOrgBounds as number
------------------------------------------------22はメニュー分を引いて縦横比を計算
set theOrgPer to theOrgW / (theOrgH - (theOrgBar + 22)) as number
------------------------------------------------ファイル名を取得
set theFileName to name
------------------------------------------------フルスクリーンにする
tell application "System Events"
keystroke "f" using command down
end tell
------------------------------------------------ここの待ち時間はマシンパワーに依存がある
------------------------------------------------フルスクリーンになってからキャプチャ撮るための待ち時間
delay 2
end tell
end tell
------------------------------------------------保存先を確定
set thePicPath to (theFileName & ".png") as string
------------------------------------------------スクリーンショットを撮影pngファイルにする
do shell script "screencapture " & quoted form of thePicPath
------------------------------------------------jpgが好みな方はこちら
------------------------------------------------保存先を確定
----set thePicPath to (theFileName & ".jpg") as string
------------------------------------------------スクリーンショットを撮影jpgファイルにする
----do shell script "screencapture -tjpg" & quoted form of thePicPath
------------------------------------------------ファイルの書き込み待ちのおまじないの待ち
delay 1
tell application "Flash Player"
activate
tell window 1
------------------------------------------------フルスクリーン時の画面サイズ
set theFullBounds to bounds as list
------------------------------------------------幅
set theFullW to item 3 of theFullBounds as number
------------------------------------------------高さ
set theFullH to item 4 of theFullBounds as number
------------------------------------------------高さから幅を計算
set theCrapW to (theFullH * theOrgPer) - 2 as integer
------------------------------------------------トリミングサイズを定義{W幅px, H高さPX}
set theCrapBounds to {theCrapW, theFullH} as list
end tell
----------------------------ESCを送ってFlash Playerフルスクリーンを閉じる
tell application "System Events"
keystroke (key code 53)
end tell
end tell
------------------------------------------------画像をトリミングする
tell application "Image Events"
------------------------------------------------スクリーンキャプチャーしたファイルを開く
set theScreenImg to open thePicPath
---------------------------------------画像サイズはSWFをフルスクリーンから左右の余白を削除
crop theScreenImg to dimensions theCrapBounds
------------------------------------------------保存して
save theScreenImg
------------------------------------------------閉じる
close theScreenImg
------------------------------------------------メモリへのおまじないで初期化しておく
set theScreenImg to ""
end tell
----------------------------Flash Playerウィンドを閉じる
tell application "Flash Player"
activate
------------------------------------------------ウィンドを閉じる
close window 1
end tell
------------------------------------------------繰り返しの終了
end repeat
end tell
end open
「swf2img.app.zip」をダウンロード
「swf2img.rtf」をダウンロード
| 固定リンク
« [swf2pdf]SWFファイルをPDFに変換する(といってもPDFに印刷する感じ) | トップページ | [swf2img]【OSX10.4】旧環境を使ってiView MediaProでSWFファイルをイメージに変換する »
「SWF」カテゴリの記事
- [swf2image]File Juice(2013.01.05)
- [swf2img]【OSX10.4】旧環境を使ってiView MediaProでSWFファイルをイメージに変換する(2012.12.23)
- [swf2img]SWFファイルをイメージファイルに変換する(といってもキャプチャー撮るだけ)(2012.12.21)
- [swf2pdf]SWFファイルをPDFに変換する(といってもPDFに印刷する感じ)(2012.12.21)



[RSS]