« [img2webp]アニメーションwebpの作成 | トップページ | [Distiller]PSファイルをPDFに変換する その2 »

[gif2webp]GIFアニメをwebpに変換する


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(* 別途 gif2webpが必要です
[applescript]libwebpインストール
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-0a1a86.html
実行してから利用してください
*)
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

###設定項目
set strBinPath to ("~/bin/libwebp/bin/gif2webp") as text

##バイナリのパス
set strBinPathStr to refMe's NSString's stringWithString:(strBinPath)
set ocidFilePath to strBinPathStr's stringByStandardizingPath()
set strBinPath to ocidFilePath as string
##デフォルトロケーション
tell application "Finder"
  set aliasDefaultLocation to container of (path to me) as alias
  set aliasDesktopFolder to (path to desktop folder from user domain) as alias
end tell
###ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
##ダイアログ
set listAliasFilePath to (choose file with prompt "GIFファイルを選んでください" default location aliasDefaultLocation of type {"com.compuserve.gif"} with invisibles and multiple selections allowed without showing package contents) as list

##選んだファイルの数だけ実行
repeat with itemAliasFilePath in listAliasFilePath
  tell application "Finder"
    set aliasFilePath to itemAliasFilePath as alias
    ###ファイルパスを取得
    set strFilePath to (POSIX path of aliasFilePath) as text
  end tell
  ###コマンド整形
  set strCommandText to ("\"" & strBinPath & "\" \"" & strFilePath & "\" -q 100 -o \"" & strFilePath & ".webp\"") as text
  ####実行
  tell application "Terminal"
launch
activate
    set objWindowID to (do script "\n\n")
delay 2
do script strCommandText in objWindowID
  end tell
  
  ####処理が終わるのをまってから次にかかる
  repeat
    tell application "Terminal"
      tell front window
        set boolTabStatus to busy
      end tell
    end tell
    if boolTabStatus is false then
      exit repeat
      --->このリピートを抜けて次の処理へ
    else if boolTabStatus is true then
delay 3
      --->busyなのであと3秒まつ
    end if
  end repeat
  
  
end repeat

|

« [img2webp]アニメーションwebpの作成 | トップページ | [Distiller]PSファイルをPDFに変換する その2 »

webp」カテゴリの記事

GIF」カテゴリの記事