LoginSignup
8
8

More than 5 years have passed since last update.

Macで複数の画像を一括でリサイズする AppleScript (サムネイル化などに)

Last updated at Posted at 2016-03-03

はじめに

 沢山の写真をWebページなどにあげようとすると、そのままでは大きすぎるのでサイズを小さくしたいときに便利な AppleScript を書きました。
 画像データが入っているフォルダを指定すると、変換するサイズ(幅のピクセル値)を聞いてきます。後は自動でフォルダ内の画像データが指定したサイズに変換されます。

注意: フォルダ内の画像は全てリサイズされ元データは残りませんので、必ずコピーをしてからご利用ください。

AppleScript のソース

 以下、ソースです。
 アイコン付きの画像データにしたいときには、
save this_img in aFile as JPEG
の行を
save this_img in aFile as JPEG with Icon
とします。

imagesize.scpt
-- 指定したフォルダー内の画像データを指定した幅になるよう縮小します。
-- 幅の指定はピクセル値で指定します。
-- 【注意】フォルダーまでのパスの中に、空白等が入っていると動作しません。
-- wtitten by ynomura.com

set outputFolder to POSIX path of (choose folder with prompt "サイズを変換する画像が入っているフォルダーを指定")
display dialog "返還後の幅をピクセル値で指定" default answer 150
set pixSize to text returned of result

set aList to list folder outputFolder
tell application "Image Events"
    launch
    repeat with img in aList
        if (text of img) = ".DS_Store" then
        else
            set aFile to outputFolder & img
            set this_img to open aFile
            scale this_img to size pixSize as integer
            save this_img in aFile as JPEG
            close this_img
        end if
    end repeat
end tell
8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8