« [sips]カラーモード | トップページ | [AppleScript]ゼロサプレス処理 »

[sips]画像の縦横サイズ pixelWidth pixelHeight

画像ファイルの縦横サイズを取得します

ダウンロード - sips2pixsize.scpt.zip

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use scripting additions

set aliasLocationPath to (path to desktop folder from user domain)
set aliasImageFilePath to (choose file of type {"public.image", "public.tiff", "public.png", "public.jpeg", "com.adobe.photoshop-image", "public.heic"} with prompt "ファイルを選んで" default location aliasLocationPath without invisibles, showing package contents and multiple selections allowed)

set theImageFilePath to POSIX path of aliasImageFilePath as text


####通常2行での応答時
set thePixelWidth to (do shell script "echo `sips --getProperty pixelWidth \"" & theImageFilePath & "\"` | cut -f 2 -d ':'| echo `cat`")
log "thePixelWidth:" & thePixelWidth
set thePixelHeight to (do shell script "echo `sips --getProperty pixelHeight \"" & theImageFilePath & "\"` | cut -f 2 -d ':'| echo `cat`")

log "thePixelWidth:" & thePixelHeight



####1Line応答時
set thePixelWidth to (do shell script "echo `sips --getProperty pixelWidth -1 \"" & theImageFilePath & "\"` | cut -f 2 -d ':'| cut -f 1 -d '|'| echo `cat`")
log "thePixelWidth:" & thePixelWidth

set thePixelHeight to (do shell script "echo `sips --getProperty pixelHeight -1 \"" & theImageFilePath & "\"` | cut -f 2 -d ':'| cut -f 1 -d '|'| echo `cat`")
log "thePixelWidth:" & thePixelHeight

return "thePixelWidth:" & thePixelHeight & "\n" & "thePixelWidth:" & thePixelHeight

sh-3.2$ sips -g all /Users/Shared/net-028.jpg

/Users/Shared/net-028.jpg

  pixelWidth: 1920

  pixelHeight: 1080

  typeIdentifier: public.jpeg

  format: jpeg

  formatOptions: default

  dpiWidth: 96.000

  dpiHeight: 96.000

  samplesPerPixel: 3

  bitsPerSample: 8

  hasAlpha: no

  space: RGB

  profile: sRGB IEC61966-2.1



sh-3.2$ sips --getProperty pixelHeight /Users/Shared/ImageFile.jpg

/Users/Shared/ImageFile.jpg

  pixelHeight: 1080

sh-3.2$ 

sh-3.2$ 

sh-3.2$ 

sh-3.2$ 

sh-3.2$ sips --getProperty pixelWidth /Users/Shared/ImageFile.jpg

/Users/Shared/ImageFile.jpg

  pixelWidth: 1920

sh-3.2$ 


|

« [sips]カラーモード | トップページ | [AppleScript]ゼロサプレス処理 »

sips」カテゴリの記事