2011-10-11 17 views

答えて

2

(Photoshopのように)スクリプト可能な画像編集アプリケーションにアクセスできない場合は、Mac OS Xに付属のImage Eventsを使用して画像を切り抜くことができます。あなたは、画像の大きさがちょうど次...

on GetImageDimensions(TheFile) -- (file path as string) as {width, height} 
    try 
     tell application "Image Events" 
      launch --we have to launch Image Events before we can use it 
      set theImage to open TheFile 
      set theImageDimensions to dimensions of theImage 
      set theImageWidth to item 1 of theImageDimensions 
      set theImageHeight to item 2 of theImageDimensions 
      return {theImageWidth, theImageHeight} 
     end tell 
    on error 
     return {-1, -1} // just in case something goes wrong 
    end try 
end GetImageDimensions 

のようなものを使用し得る...と画像をトリミングするためのコマンドは偶然、もし

crop pathToFile to dimensions {cropWidth, cropHeight} 

と同じくらい簡単であるために、 Photoshopを使用している場合、切り抜きは別の方法で処理されます。

さらに多くのコマンドがありますが、必須のパラメータです。他のアプリケーションはおそらく異なる実装を持っているでしょう(おそらく、Appleのように)。選択した画像編集アプリケーションを選択して、その辞書がどのように機能するか見ることができます。

7

ImageMagickが使いやすくなります。これはinput-1.pngとしてinput-0.pngと右半分と左半分を保存します。

convert input.png -crop 50%x100% +repage input.png 

これはright.pngとしてちょうど半分を保存します。

convert input.png -gravity east -crop 50%x100% +repage right.png 

+repageは、古いキャンバスサイズのメタデータを削除します。 http://www.imagemagick.org/Usage/crop/を参照してください。

brew install imagemagickまたはsudo port install imagemagickでImageMagickをインストールできます。

+0

必ずお勧めします。これを 'do shell script'を介してアプリスクリプトで実行することもできます。 – eykanal

関連する問題