sipsコマンド

sipsは**scriptable image processing system.**の略です。

This tool is used to query or modify raster image files and ColorSync ICC profiles.

Its functionality can also be used through the “Image Events” AppleScript suite.

簡単な使い方

画像の情報を参照

スマフォで撮影した画像を見てみるとこんな感じの情報が取得できました。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
$ sips -g all sample.jpg
/PATH/sample.jpg
  pixelWidth: 4608
  pixelHeight: 2304
  typeIdentifier: public.jpeg
  format: jpeg
  formatOptions: default
  dpiWidth: 72.000
  dpiHeight: 72.000
  samplesPerPixel: 3
  bitsPerSample: 8
  hasAlpha: no
  space: RGB
  profile: sRGB IEC61966-2.1
  creation: 2018:08:04 09:39:37
  make: XXXXXX
  model: XXXXXXXXXXXX
  software: XXXXXXXXXXXX

必要な項目だけ出力したい場合は、パラメータを指定すると可能です。

1
2
3
4
$ sips -g pixelHeight -g pixelWidth sample.jpg
/PATH/sample.jpg
  pixelHeight: 2304
  pixelWidth: 4608

画像をリサイズする

縦横を640×640に収まるようにしてみる

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
$ sips -Z 640 sample.jpg
/PATH/sample.jpg
<CGColor 0x7ff75a508840> [<CGColorSpace 0x7ff75a701d30> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
  /PATH/sample.jpg

# リサイズ後
$ sips -g pixelHeight -g pixelWidth sample.jpg
/PATH/sample.jpg
  pixelHeight: 320
  pixelWidth: 640

ヘルプ

他にもいろいろできるので、ヘルプを見ながら試すのもいいかも。

macのプレビュー.appで編集できそうな項目は、だいたいできそうな感じですね。

使い方

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$ sips --help
sips 10.4.4 - scriptable image processing system.
This tool is used to query or modify raster image files and ColorSync ICC profiles.
Its functionality can also be used through the "Image Events" AppleScript suite.

  Usages:
    sips [-h, --help]
    sips [-H, --helpProperties]

    sips [image-query-functions] imagefile ...

    sips [profile-query-functions] profile ...

    sips [image modification functions] imagefile ...
         [--out result-file-or-dir]

    sips [profile modification functions] profile ...
         [--out result-file-or-dir]


  Profile query functions:
    -g, --getProperty key
    -X, --extractTag tag tagFile
    -v, --verify

  Image query functions:
    -g, --getProperty key
    -x, --extractProfile profile

  Profile modification functions:
    -s, --setProperty key value
    -d, --deleteProperty key
        --deleteTag tag
        --copyTag srcTag dstTag
        --loadTag tag tagFile
        --repair

  Image modification functions:
    -s, --setProperty key value
    -d, --deleteProperty key
    -e, --embedProfile profile
    -E, --embedProfileIfNone profile
    -m, --matchTo profile
    -M, --matchToWithIntent profile intent
        --deleteColorManagementProperties
    -r, --rotate degreesCW
    -f, --flip horizontal|vertical
    -c, --cropToHeightWidth pixelsH pixelsW
    -p, --padToHeightWidth pixelsH pixelsW
        --padColor hexcolor
    -z, --resampleHeightWidth pixelsH pixelsW
        --resampleWidth pixelsW
        --resampleHeight pixelsH
    -Z, --resampleHeightWidthMax pixelsWH
    -i, --addIcon
    -o, --optimizeColorForSharing

設定値

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$ sips -H
sips 10.4.4 - scriptable image processing system.
This tool is used to query or modify raster image files and ColorSync ICC profiles.
Its functionality can also be used through the "Image Events" AppleScript suite.

  The commands --getProperty, --setProperty, and --deleteProperty
  can use one of the following keys as a parameter.

  Special property keys:
    all                  binary data
    allxml               binary data

  Image property keys:
    dpiHeight            float
    dpiWidth             float
    pixelHeight          integer (read-only)
    pixelWidth           integer (read-only)
    typeIdentifier       string (read-only)
    format               string jpeg | tiff | png | gif | jp2 | pict | bmp | qtif | psd | sgi | tga
    formatOptions        string default | [low|normal|high|best|<percent>] | [lzw|packbits]
    space                string (read-only)
    samplesPerPixel      integer (read-only)
    bitsPerSample        integer (read-only)
    creation             string (read-only)
    make                 string
    model                string
    software             string (read-only)
    description          string
    copyright            string
    artist               string
    profile              binary data
    hasAlpha             boolean (read-only)

  Profile property keys:
    description          utf8 string
    size                 integer (read-only)
    cmm                  string
    version              string
    class                string (read-only)
    space                string (read-only)
    pcs                  string (read-only)
    creation             string
    platform             string
    quality              string normal | draft | best
    deviceManufacturer   string
    deviceModel          integer
    deviceAttributes0    integer
    deviceAttributes1    integer
    renderingIntent      string perceptual | relative | saturation | absolute
    creator              string
    copyright            string
    md5                  string (read-only)