« [ViewSettingsDictionary]タグのリストの収集 | トップページ | OpenSaveパネルを終了させる »

カラーモード判定


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

#!/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 framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()


set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
###ダイアログ
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 listUTI to {"public.image"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set listAliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles, showing package contents and multiple selections allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try

set numCntFile to (count of listAliasFilePath) as integer
tell application "Image Events" to activate
repeat with itemIntNo from 1 to numCntFile by 1
  tell application "Image Events"
    set objImage to open item numCntFile of listAliasFilePath
    set strColorSpace to (color space of objImage) as text
    if strColorSpace is "RGB" then
log "カラーは" & strColorSpace & "です"
      
    else if strColorSpace is "CMYK" then
log "カラーは" & strColorSpace & "です"
      
    end if
close objImage
  end tell
end repeat



#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
#################################################

STR_FILE_PATH="/Library/User Pictures/Fun/Medal.heic"

STR_RESPONSE=$(/usr/bin/sips --getProperty space "$STR_FILE_PATH")
/bin/echo "$STR_RESPONSE"

if [[ "$STR_RESPONSE" == *CMYK* ]]; then
/bin/echo "CMYK画像です"

elif [[ "$STR_RESPONSE" == *RGB* ]]; then
/bin/echo "RGB画像です"

fi

exit 0


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

#!/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 framework "Foundation"
use scripting additions
property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()


set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
###ダイアログ
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 listUTI to {"public.image"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set listAliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles, showing package contents and multiple selections allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try

repeat with itemAliasFilePath in listAliasFilePath
  set aliasFilePath to itemAliasFilePath as alias
  set strFilePath to (POSIX path of aliasFilePath) as text
  set strCommandText to ("/usr/bin/sips --getProperty space \"" & strFilePath & "\"")
  set strResponse to (do shell script strCommandText) as text
  if strResponse contains "RGB" then
log "カラーはRGBです"
    
  else if strResponse contains "CMYK" then
log "カラーはCMYKです"
    
  end if
end repeat


|

« [ViewSettingsDictionary]タグのリストの収集 | トップページ | OpenSaveパネルを終了させる »

AppleScript Image Events」カテゴリの記事

AppleScript Color」カテゴリの記事