NSBezierPath

[NSBezierPath]チェキSQサイズの画像のフレームを作成する

まずはここまでの画像(フレーム部分)まで生成します
202411150244141_1476x736
AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use framework "Foundation"
008use framework "UniformTypeIdentifiers"
009use framework "AppKit"
010#use framework "Carbon"
011use scripting additions
012property refMe : a reference to current application
013
014#
015set appFileManager to refMe's NSFileManager's defaultManager()
016set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask))
017set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
018#
019set ocidSaveDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("TemporaryItems") isDirectory:(true)
020set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
021# 777-->511 755-->493 700-->448 766-->502
022ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
023set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
024##
025
026set numW to 408 as integer
027set numH to 488 as integer
028set strDateTime to doGetNextDateNo({"yyyyMMddhhmm", 1})
029set strFileName to (strDateTime & "-" & numW & "x" & numH & "@144") as text
030set ocidSaveBasePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:(false)
031set ocidSaveFilePathURL to ocidSaveBasePathURL's URLByAppendingPathExtension:("png")
032#####
033#カラーICC
034set strIccFilePath to ("/System/Library/ColorSync/Profiles/sRGB Profile.icc") as text
035set ocidIccFilePathStr to refMe's NSString's stringWithString:(strIccFilePath)
036set ocidIccFilePath to ocidIccFilePathStr's stringByStandardizingPath
037set ocidIccFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidIccFilePath) isDirectory:(false)
038set ocidProfileData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidIccFilePathURL)
039#セットするRECT
040set ocidDrawRect to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
041# RGB系のカラースペース
042set ocidColorSpaceName to (refMe's NSCalibratedRGBColorSpace)
043# アルファあり
044set ocidBitmapFormat to (refMe's NSAlphaFirstBitmapFormat)
045#アートボード
046set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numW) pixelsHigh:(numH) bitsPerSample:(8) samplesPerPixel:(4) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(0) bitsPerPixel:(32))
047#
048#カラーを定義
049set ocidBackgroundColor to (refMe's NSColor's colorWithSRGBRed:(1) green:(1) blue:(1) alpha:(1))
050set ocidAlphaColor to (refMe's NSColor's colorWithSRGBRed:(1) green:(1) blue:(1) alpha:(0))
051###########################
052####【NSGraphicsContext's】▼
053refMe's NSGraphicsContext's saveGraphicsState()
054#Context 選択した画像を読み込んで
055set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
056(ocidSetImageContext's setShouldAntialias:(true))
057(ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
058(ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentRelativeColorimetric))
059#生成された画像でNSGraphicsContext初期化
060(refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
061
062#【1】RGB値で背景色=白をセットして
063ocidBackgroundColor's |set|()
064#指定した色で背景を塗る
065refMe's NSRectFill(ocidDrawRect)
066
067
068#マスクパス角丸20PX
069set ocidMaskRect to refMe's NSRect's NSMakeRect(28, 108, 352, 352)
070set ocidMaskPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidMaskRect) xRadius:(4) yRadius:(4)
071#【2】マスクをセット
072ocidMaskPath's addClip()
073
074#【3】アルファ=透過をマスク内に指定する
075ocidAlphaColor's |set|()
076#透過色をマスク範囲内に指定
077refMe's NSRectFill(ocidMaskRect)
078
079#処理終了
080refMe's NSGraphicsContext's restoreGraphicsState()
081####【NSGraphicsContext's】▲
082
083
084###########################
085#解像度セット
086set numPPI to 144 as integer
087set numWpt to ((numW / numPPI) * 72) as integer
088set numHpt to ((numH / numPPI) * 72) as integer
089set ocidSetSize to refMe's NSSize's NSMakeSize(numWpt, numHpt)
090ocidArtBoardRep's setSize:(ocidSetSize)
091
092#保存オプション
093set ocidProperty to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
094(ocidProperty's setObject:(refMe's NSNumber's numberWithBool:false) forKey:(refMe's NSImageInterlaced))
095(ocidProperty's setObject:(refMe's NSNumber's numberWithDouble:(1 / 2.2)) forKey:(refMe's NSImageGamma))
096(ocidProperty's setObject:(ocidProfileData) forKey:(refMe's NSImageColorSyncProfileData))
097
098#保存データに変換
099set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidProperty))
100#保存
101set boolDone to (ocidNSInlineData's writeToURL:(ocidSaveFilePathURL) atomically:true)
102###保存先を開く
103set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
104set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
105
106
107
108
109################################
110# 明日の日付 doGetDateNo(argDateFormat,argCalendarNO)
111# argCalendarNO 1 NSCalendarIdentifierGregorian 西暦
112# argCalendarNO 2 NSCalendarIdentifierJapanese 和暦
113################################
114to doGetNextDateNo({argDateFormat, argCalendarNO})
115  ##渡された値をテキストで確定させて
116  set strDateFormat to argDateFormat as text
117  set intCalendarNO to argCalendarNO as integer
118  ###日付情報の取得
119  set ocidDate to current application's NSDate's |date|()
120  set ocidIntervalt to current application's NSDate's dateWithTimeIntervalSinceNow:(86400)
121  ###日付のフォーマットを定義(日本語)
122  set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init()
123  ###和暦 西暦 カレンダー分岐
124  if intCalendarNO = 1 then
125    set ocidCalendarID to (current application's NSCalendarIdentifierGregorian)
126  else if intCalendarNO = 2 then
127    set ocidCalendarID to (current application's NSCalendarIdentifierJapanese)
128  else
129    set ocidCalendarID to (current application's NSCalendarIdentifierISO8601)
130  end if
131  set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(ocidCalendarID)
132  set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
133  set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX")
134  ###設定
135  ocidFormatterJP's setTimeZone:(ocidTimezoneJP)
136  ocidFormatterJP's setLocale:(ocidLocaleJP)
137  ocidFormatterJP's setCalendar:(ocidCalendarJP)
138  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterNoStyle)
139  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterShortStyle)
140  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterMediumStyle)
141  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterLongStyle)
142  ocidFormatterJP's setDateStyle:(current application's NSDateFormatterFullStyle)
143  ###渡された値でフォーマット定義
144  ocidFormatterJP's setDateFormat:(strDateFormat)
145  ###フォーマット適応
146  set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidIntervalt)
147  ###テキストで戻す
148  set strDateAndTime to ocidDateAndTime as text
149  return strDateAndTime
150end doGetNextDateNo
151return
152
AppleScriptで生成しました

|

[NSGraphicsContext]中抜きマスクにより画像の合成


ダウンロード - makeimagemask.zip



SNS等への投稿用


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use framework "Foundation"
008use framework "UniformTypeIdentifiers"
009use framework "AppKit"
010#use framework "Carbon"
011use scripting additions
012property refMe : a reference to current application
013
014#############################
015#【1】設定項目 
016#Dataフォルダ内にあるファイルから1つ
017set strRandomColorFileNameRGB to ("TOKYO SEEDS.tsv") as text
018#ロゴ画像データ imagesフォルダ内に入れてください
019set strLogoFileName to ("logo-140x140@72.png") as text
020#解像度変更するか? true=144ppi false=72ppi
021set booldHightResolution to false as boolean
022
023#############################
024#【2】PANTONE カラーデータを読み込む
025set aliasPathToMe to (path to me) as alias
026set strPathToMe to (POSIX path of aliasPathToMe) as text
027set ocidPathToMeStr to refMe's NSString's stringWithString:(strPathToMe)
028set ocidPathToMe to ocidPathToMeStr's stringByStandardizingPath()
029set ocidPathToMeURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidPathToMe) isDirectory:false)
030set ocidContainerDirPathURL to ocidPathToMeURL's URLByDeletingLastPathComponent()
031set strSetPath to ("Data/" & strRandomColorFileNameRGB) as text
032set ocidColorFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strSetPath) isDirectory:(false)
033set listResponse to refMe's NSString's alloc()'s initWithContentsOfURL:(ocidColorFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
034if (item 2 of listResponse) = (missing value) then
035  set ocidReadStrings to (item 1 of listResponse)
036else if (item 2 of listResponse) ≠ (missing value) then
037  set strErrorNO to (item 2 of listResponse)'s code() as text
038  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
039  refMe's NSLog("■:" & strErrorNO & strErrorMes)
040  return "エラーしました" & strErrorNO & strErrorMes
041end if
042#改行をUNIXに強制
043set ocidReadStringsTMP to (ocidReadStrings's stringByReplacingOccurrencesOfString:("\n\r") withString:("\n"))
044set ocidReadStringsTMP to (ocidReadStringsTMP's stringByReplacingOccurrencesOfString:("\r") withString:("\n"))
045set ocidReadStrings to (ocidReadStringsTMP's stringByReplacingOccurrencesOfString:("\n\n") withString:("\n"))
046#文末最後が改行の場合は最後の改行を削除する
047set boolLastReturn to (ocidReadStrings's hasSuffix:("\n")) as boolean
048if boolLastReturn is true then
049  set numStringLength to ocidReadStrings's |length|() as integer
050  set ocidReadStringM to ocidReadStrings's substringToIndex:(numStringLength - 1)
051else
052  set ocidReadStringM to ocidReadStrings
053end if
054#改行区切りでArrayにする
055set ocidColorItemArray to ocidReadStringM's componentsSeparatedByString:("\n")
056#リストの数を数えて
057set numCntArray to (ocidColorItemArray's |count|()) as integer
058#どの色にするか? ランダムの値にする
059set numRandomNO to random number from 0 to (numCntArray - 1)
060#ランダムの値で行データ=リストを取得する
061set ocidLineString to ocidColorItemArray's objectAtIndex:(numRandomNO)
062#タブで各値を格納
063set ocidColorCodeArray to ocidLineString's componentsSeparatedByString:("\t")
064#8BIT カラーの値を 整数に変換
065set str8bitR to (item 2 of ocidColorCodeArray) as text
066set str8bitG to (item 3 of ocidColorCodeArray) as text
067set str8bitB to (item 4 of ocidColorCodeArray) as text
068set ocid8bitR to refMe's NSDecimalNumber's alloc()'s initWithString:(str8bitR)
069set ocid8bitG to refMe's NSDecimalNumber's alloc()'s initWithString:(str8bitG)
070set ocid8bitB to refMe's NSDecimalNumber's alloc()'s initWithString:(str8bitB)
071set ocid8bit to refMe's NSDecimalNumber's alloc()'s initWithString:("255")
072set ocidFloatR to (ocid8bitR's decimalNumberByDividingBy:(ocid8bit))
073set ocidFloatG to (ocid8bitG's decimalNumberByDividingBy:(ocid8bit))
074set ocidFloatB to (ocid8bitB's decimalNumberByDividingBy:(ocid8bit))
075set numFloatR to ocidFloatR's floatValue() as number
076set numFloatG to ocidFloatG's floatValue() as number
077set numFloatB to ocidFloatB's floatValue() as number
078set numFloatA to (1) as number
079#カラーを定義
080set ocidBackgroundColor to (refMe's NSColor's colorWithSRGBRed:(numFloatR) green:(numFloatG) blue:(numFloatB) alpha:(numFloatA))
081#色の名前を取得して描画用にStringにしておく
082set strColorName to (item 1 of ocidColorCodeArray) as text
083set ocidText to (refMe's NSString's stringWithString:(strColorName))
084########################
085#【3】合成画像
086#デフォルトパス
087set appFileManager to refMe's NSFileManager's defaultManager()
088set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask))
089set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
090set ocidSetImageDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/AutomatorExport") isDirectory:(true)
091set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
092ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
093set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSetImageDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
094#ダイアログ
095set strName to (name of current application) as text
096if strName is "osascript" then
097  tell application "Finder" to activate
098else
099  tell current application to activate
100end if
101#自分用
102set ocidURLsArray to appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask)
103set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
104set ocidAutomatorExportDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/AutomatorExport") isDirectory:(false)
105set aliasDefaultLocation to (ocidAutomatorExportDirPathURL's absoluteURL()) as alias
106(* 一般用
107set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
108set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
109set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
110*)
111set listUTI to {"public.image"}
112set strMes to ("画像ファイルを選んでください") as text
113set strPrompt to ("画像ファイルを選んでください") as text
114try
115  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
116on error
117  log "エラーしました"
118  return "エラーしました"
119end try
120#セットする画像のパス
121set strSetImageFilePath to (POSIX path of aliasFilePath) as text
122set ocidSetImageFilePathStr to refMe's NSString's stringWithString:(strSetImageFilePath)
123set ocidSetImageFilePath to ocidSetImageFilePathStr's stringByStandardizingPath()
124set ocidSetImageFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSetImageFilePath) isDirectory:false)
125
126########################
127#【4】画像読み込み
128set ocidOption to (refMe's NSDataReadingMappedIfSafe)
129set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidSetImageFilePathURL) options:(ocidOption) |error| :(reference)
130set ocidSetImageData to (item 1 of listResponse)
131#NSImage's
132set ocidSetImage to refMe's NSImage's alloc()'s initWithData:(ocidSetImageData)
133set ocidSetImageRepArray to ocidSetImage's representations()
134set ocidSetImageRep to ocidSetImageRepArray's firstObject()
135set numSetImagePixelsWidth to ocidSetImageRep's pixelsWide()
136set numSetImagePixelsHeight to ocidSetImageRep's pixelsHigh()
137
138#サイズ計算 幅 縦 最大1060で縦横比を保持する
139if numSetImagePixelsWidth > numSetImagePixelsHeight then
140  set numRatio to (numSetImagePixelsHeight / numSetImagePixelsWidth) as number
141  set numDiffW to (1060 - numSetImagePixelsWidth)
142  set numSetW to (numSetImagePixelsWidth + numDiffW) as integer
143  set numSetH to (numSetW * numRatio) as integer
144  set numDiffH to (820 - numSetH) as integer
145else if numSetImagePixelsWidth ≤ numSetImagePixelsHeight then
146  set numRatio to (numSetImagePixelsWidth / numSetImagePixelsHeight) as number
147  set numDiffH to (820 - numSetImagePixelsHeight) as number
148  set numSetH to (numSetImagePixelsHeight + numDiffH) as integer
149  set numSetW to (numSetH * numRatio) as integer
150  set numDiffW to (1060 - numSetW) as integer
151end if
152#最終的なDRAWRECTを計算
153set numPasteX to (1060 - numSetW) / 2 + 10 as integer
154set numPasteY to ((1060 - numSetH) / 2) + 130 as integer
155set ocidSetImageDrawRect to refMe's NSRect's NSMakeRect(numPasteX, numPasteY, numSetW, numSetH)
156set ocidSetImageFromRect to refMe's NSRect's NSMakeRect(0, 0, numSetImagePixelsWidth, numSetImagePixelsHeight)
157log ocidSetImageFromRect
158log ocidSetImageDrawRect
159
160########################
161#【5】画像保存先
162set ocidSaveDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/PostImage") isDirectory:(true)
163set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
164########################
165#【6】ロゴマーク読み込み
166set strSetValue to ("images/" & strLogoFileName) as text
167set ocidLogoFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strSetValue) isDirectory:(false)
168#ロゴマーク読み込みNSData's
169set ocidOption to (refMe's NSDataReadingMappedIfSafe)
170set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidLogoFilePathURL) options:(ocidOption) |error| :(reference)
171set ocidLogoData to (item 1 of listResponse)
172#NSImage's
173set ocidLogoImage to refMe's NSImage's alloc()'s initWithData:(ocidLogoData)
174set ocidLogoImageRepArray to ocidLogoImage's representations()
175set ocidLogoImageRep to ocidLogoImageRepArray's firstObject()
176#ロゴマークのペースト位置のRECT
177set ocidLogoDrawRect to refMe's NSRect's NSMakeRect(920, 10, 140, 140)
178set ocidLogoFromRect to refMe's NSRect's NSMakeRect(0, 0, 140, 140)
179
180########################
181#【7】画像生成開始
182set listResponse to {1080, 1080} as list
183set numW to (item 1 of listResponse) as integer
184set numH to (item 2 of listResponse) as integer
185set strDateTime to doGetNextDateNo({"yyyyMMddhhmm", 1})
186set strFileName to (strDateTime & "-" & numW & "x" & numH & "@144") as text
187set ocidSaveBasePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:(false)
188set ocidSaveFilePathURL to ocidSaveBasePathURL's URLByAppendingPathExtension:("png")
189#カラーICC
190set strIccFilePath to ("/System/Library/ColorSync/Profiles/sRGB Profile.icc") as text
191set ocidIccFilePathStr to refMe's NSString's stringWithString:(strIccFilePath)
192set ocidIccFilePath to ocidIccFilePathStr's stringByStandardizingPath
193set ocidIccFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidIccFilePath) isDirectory:(false)
194set ocidProfileData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidIccFilePathURL)
195#セットするRECT
196set ocidDrawRect to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
197# RGB系のカラースペース
198set ocidColorSpaceName to (refMe's NSCalibratedRGBColorSpace)
199# アルファあり
200set ocidBitmapFormat to (refMe's NSAlphaFirstBitmapFormat)
201#アートボード
202set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numW) pixelsHigh:(numH) bitsPerSample:(8) samplesPerPixel:(4) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(0) bitsPerPixel:(32))
203
204########################
205#【8】最下層アートボード
206set ocidArtBoardColor to (refMe's NSColor's colorWithSRGBRed:(numFloatR) green:(numFloatG) blue:(numFloatB) alpha:(numFloatA))
207####【NSGraphicsContext's】
208refMe's NSGraphicsContext's saveGraphicsState()
209#Context 選択した画像を読み込んで
210set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
211(ocidSetImageContext's setShouldAntialias:(true))
212(ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
213(ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentRelativeColorimetric))
214#生成された画像でNSGraphicsContext初期化
215(refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
216#外側の角丸のマスク
217set ocidMaskRect to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
218set ocidMaskPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidDrawRect) xRadius:(40) yRadius:(40)
219ocidMaskPath's addClip()
220#RGB値で背景色をセットして
221ocidArtBoardColor's |set|()
222#指定した色で背景を塗る
223refMe's NSRectFill(ocidDrawRect)
224#画像をNSCompositingOperationSourceOver
225#(ocidSetImageRep's drawInRect:(ocidSetImageDrawRect) fromRect:(ocidSetImageFromRect) operation:(refMe's NSCompositingOperationSourceOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
226#外側の角丸のマスク
227set ocidMaskRect to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
228set ocidMaskPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidDrawRect) xRadius:(40) yRadius:(40)
229ocidMaskPath's addClip()
230(ocidSetImageRep's drawInRect:(ocidSetImageDrawRect) fromRect:(refMe's NSZeroRect) operation:(refMe's NSCompositingOperationSourceOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
231#処理終了
232refMe's NSGraphicsContext's restoreGraphicsState()
233####【NSGraphicsContext's】
234
235########################
236#【9】画像の上に来るフレーム
237#色指定
238set ocidBaseBoardColor to (refMe's NSColor's colorWithSRGBRed:(numFloatR) green:(numFloatG) blue:(numFloatB) alpha:(numFloatA))
239#サイズ
240set baseSiezeWPx to 1080 as integer
241set baseSiezeHPx to 1080 as integer
242#ドロップシャドウ初期化
243set ocidSetShadow to refMe's NSShadow's alloc()'s init()
244set ocidOffSetSize to refMe's NSSize's NSMakeSize(0, 0)
245ocidSetShadow's setShadowOffset:(ocidOffSetSize)
246ocidSetShadow's setShadowBlurRadius:(20)
247set ocidShadowColor to refMe's NSColor's colorWithCalibratedWhite:(0) alpha:(0.5)
248ocidSetShadow's setShadowColor:(ocidShadowColor)
249#アートボード
250set ocidBaseBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numW) pixelsHigh:(numH) bitsPerSample:(8) samplesPerPixel:(4) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(0) bitsPerPixel:(32))
251####【NSGraphicsContext's】
252refMe's NSGraphicsContext's saveGraphicsState()
253#Context 選択した画像を読み込んで
254set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidBaseBoardRep))
255(ocidSetImageContext's setShouldAntialias:(true))
256(ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
257(ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentRelativeColorimetric))
258#生成された画像でNSGraphicsContext初期化
259(refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
260#外側の角丸のマスク
261set ocidMaskRectOut to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
262set ocidMaskOutPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidMaskRectOut) xRadius:(40) yRadius:(40)
263#ocidMaskPath's addClip()
264#インマスク
265set ocidMaskRectIn to refMe's NSRect's NSMakeRect(20, 260, 1040, 800)
266set ocidMaskInPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidMaskRectIn) xRadius:(40) yRadius:(40)
267ocidMaskOutPath's appendBezierPath:(ocidMaskInPath)
268ocidMaskOutPath's setWindingRule:(refMe's NSEvenOddWindingRule)
269ocidMaskOutPath's addClip()
270#RGB値で背景色をセットして
271ocidBaseBoardColor's |set|()
272#指定した色で背景を塗る
273refMe's NSRectFill(ocidDrawRect)
274#外側の角丸のマスク
275set ocidMaskRect to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
276set ocidMaskPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidDrawRect) xRadius:(40) yRadius:(40)
277ocidMaskPath's addClip()
278#ロゴマークをNSCompositingOperationSourceOver
279(ocidLogoImageRep's drawInRect:(ocidLogoDrawRect) fromRect:(ocidLogoFromRect) operation:(refMe's NSCompositingOperationSourceOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
280#処理終了
281refMe's NSGraphicsContext's restoreGraphicsState()
282####【NSGraphicsContext's】
283
284########################
285#【10】アートボードにフレームをペースト
286set ocidDrawRect to refMe's NSRect's NSMakeRect(0, 0, 1080, 1080)
287set ocidFromRect to refMe's NSRect's NSMakeRect(0, 0, 1080, 1080)
288####【NSGraphicsContext's】
289refMe's NSGraphicsContext's saveGraphicsState()
290#Context 選択した画像を読み込んで
291set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
292(ocidSetImageContext's setShouldAntialias:(true))
293(ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
294(ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentRelativeColorimetric))
295#生成された画像でNSGraphicsContext初期化
296(refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
297#シャドウをセットして
298ocidSetShadow's |set|()
299#外側の角丸のマスク
300set ocidMaskRect to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
301set ocidMaskPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidDrawRect) xRadius:(40) yRadius:(40)
302ocidMaskPath's addClip()
303#背景画像の上NSCompositeSourceOver
304set appOperation to (refMe's NSCompositeSourceOver)
305ocidBaseBoardRep's drawInRect:(ocidDrawRect) fromRect:(ocidFromRect) operation:(appOperation) fraction:1.0 respectFlipped:true hints:(missing value)
306#処理終了
307refMe's NSGraphicsContext's restoreGraphicsState()
308####【NSGraphicsContext's】
309
310########################
311#【11】カラーバー4色
312set ocidWhiteColor to (refMe's NSColor's colorWithSRGBRed:(1) green:(1) blue:(1) alpha:(1))
313set numFirstDiv to 1.1 as number
314set numSecondDiv to 1.15 as number
315set numThirdDiv to 1.2 as number
316set numFourthDiv to 1.25 as number
317set ocidWhiteColor8 to (refMe's NSColor's colorWithSRGBRed:(numFloatR * numFirstDiv) green:(numFloatG * numFirstDiv) blue:(numFloatB * numFirstDiv) alpha:(numFloatA))
318set ocidWhiteColor6 to (refMe's NSColor's colorWithSRGBRed:(numFloatR * numSecondDiv) green:(numFloatG * numSecondDiv) blue:(numFloatB * numSecondDiv) alpha:(numFloatA))
319set ocidWhiteColor4 to (refMe's NSColor's colorWithSRGBRed:(numFloatR * numThirdDiv) green:(numFloatG * numThirdDiv) blue:(numFloatB * numThirdDiv) alpha:(numFloatA))
320set ocidWhiteColor2 to (refMe's NSColor's colorWithSRGBRed:(numFloatR * numFourthDiv) green:(numFloatG * numFourthDiv) blue:(numFloatB * numFourthDiv) alpha:(numFloatA))
321set listWhiteColor to {ocidWhiteColor8, ocidWhiteColor6, ocidWhiteColor4, ocidWhiteColor2} as list
322#描画位置のRECT
323set ocidWhiteColor8Rect to refMe's NSRect's NSMakeRect(20, 160, 250, 90)
324set ocidWhiteColor6Rect to refMe's NSRect's NSMakeRect(282, 160, 250, 90)
325set ocidWhiteColor4Rect to refMe's NSRect's NSMakeRect(544, 160, 250, 90)
326set ocidWhiteColor2Rect to refMe's NSRect's NSMakeRect(807, 160, 250, 90)
327set listWhiteColorRect to {ocidWhiteColor8Rect, ocidWhiteColor6Rect, ocidWhiteColor4Rect, ocidWhiteColor2Rect} as list
328#カラーバー用画像を4つ
329repeat with itemNO from 1 to 4 by 1
330  set itemWColor to (item itemNO of listWhiteColor)
331  set itemWColorRect to (item itemNO of listWhiteColorRect)
332  set ocidColorBarRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(240) pixelsHigh:(90) bitsPerSample:(8) samplesPerPixel:(4) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(0) bitsPerPixel:(32))
333  ####【NSGraphicsContext's】
334  refMe's NSGraphicsContext's saveGraphicsState()
335  #Context 選択した画像を読み込んで
336  set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
337  (ocidSetImageContext's setShouldAntialias:(true))
338  (ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
339  (*    setColorRenderingIntent
340 標準
341  NSColorRenderingIntentDefault
342  絶対的な色彩を保持  (色の再現重視 印刷向き)
343  NSColorRenderingIntentAbsoluteColorimetric
344  相対的な色彩を保持 (全体的なバランス重視 モニター向き)
345  NSColorRenderingIntentRelativeColorimetric
346  知覚的な色再現  (写真向き 色数が多い場合)
347  NSColorRenderingIntentPerceptual
348  彩度を優先 (グラフィック向き 色数が少ない場合)
349  NSColorRenderingIntentSaturation
350  *)
351  (ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentSaturation))
352  (ocidSetImageContext's setCompositingOperation:(refMe's NSCompositingOperationMultiply))
353  #生成された画像でNSGraphicsContext初期化
354  (refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
355  #外側の角丸のマスク
356  set ocidMaskOutPath to (refMe's NSBezierPath's bezierPathWithRoundedRect:(itemWColorRect) xRadius:(20) yRadius:(20))
357  ocidMaskOutPath's addClip()
358  #RGB値で背景色をセットして
359  # ocidWhiteColor's setFill()
360  #指定した色で背景を塗る
361  # refMe's NSRectFill(itemWColorRect)
362  
363  itemWColor's setFill()
364  #指定した色で背景を塗る
365  refMe's NSRectFill(itemWColorRect)
366  #処理終了
367  refMe's NSGraphicsContext's restoreGraphicsState()
368  ####【NSGraphicsContext's】
369end repeat
370
371########################
372#【12】文字入れ
373###フォント初期化
374set appFontManager to refMe's NSFontManager
375set appSharedMaanager to appFontManager's sharedFontManager()
376set ocidTextAttr to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
377set ocidStyle to refMe's NSParagraphStyle's defaultParagraphStyle()
378(ocidTextAttr's setObject:(ocidStyle) forKey:(refMe's NSParagraphStyleAttributeName))
379#テキストカラー黒
380set ocidTextColor to (refMe's NSColor's colorWithSRGBRed:(0) green:(0) blue:(0) alpha:(1.0))
381(ocidTextAttr's setObject:(ocidTextColor) forKey:(refMe's NSForegroundColorAttributeName))
382####【NSGraphicsContext's】
383refMe's NSGraphicsContext's saveGraphicsState()
384set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
385###ArtBoardでNSGraphicsContext初期化
386(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
387#フォント指定
388set ocidFont to (refMe's NSFont's fontWithName:("Helvetica-Bold") |size|:(52))
389(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
390(ocidTextAttr's setObject:(-1.8) forKey:(refMe's NSKernAttributeName))
391set ocidTextOrigin to refMe's NSMakePoint((30), (20))
392#テキストを描画
393(ocidText's drawAtPoint:(ocidTextOrigin) withAttributes:(ocidTextAttr))
394#画像作成終了
395refMe's NSGraphicsContext's restoreGraphicsState()
396####【NSGraphicsContext's】
397
398########################
399#【13】解像度変更
400if booldHightResolution is false then
401  set ocidSetSize to refMe's NSSize's NSMakeSize(numW, numH)
402  ocidArtBoardRep's setSize:(ocidSetSize)
403else if booldHightResolution is true then
404  set numPPI to 144 as integer
405  set numWpt to ((numW / numPPI) * 72) as integer
406  set numHpt to ((numH / numPPI) * 72) as integer
407  set ocidSetSize to refMe's NSSize's NSMakeSize(numWpt, numHpt)
408  ocidArtBoardRep's setSize:(ocidSetSize)
409end if
410
411########################
412#【14】保存
413set ocidProperty to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
414(ocidProperty's setObject:(refMe's NSNumber's numberWithBool:false) forKey:(refMe's NSImageInterlaced))
415(ocidProperty's setObject:(refMe's NSNumber's numberWithDouble:(1 / 2.2)) forKey:(refMe's NSImageGamma))
416(ocidProperty's setObject:(ocidProfileData) forKey:(refMe's NSImageColorSyncProfileData))
417
418#保存データに変換
419set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidProperty))
420#保存
421set boolDone to (ocidNSInlineData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error| :(reference))
422
423
424########################
425#【15】保存先を開く
426set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
427set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
428log boolDone
429
430
431################################
432# 明日の日付 doGetDateNo(argDateFormat,argCalendarNO)
433# argCalendarNO 1 NSCalendarIdentifierGregorian 西暦
434# argCalendarNO 2 NSCalendarIdentifierJapanese 和暦
435################################
436to doGetNextDateNo({argDateFormat, argCalendarNO})
437  ##渡された値をテキストで確定させて
438  set strDateFormat to argDateFormat as text
439  set intCalendarNO to argCalendarNO as integer
440  ###日付情報の取得
441  set ocidDate to current application's NSDate's |date|()
442  set ocidIntervalt to current application's NSDate's dateWithTimeIntervalSinceNow:(86400)
443  ###日付のフォーマットを定義(日本語)
444  set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init()
445  ###和暦 西暦 カレンダー分岐
446  if intCalendarNO = 1 then
447    set ocidCalendarID to (current application's NSCalendarIdentifierGregorian)
448  else if intCalendarNO = 2 then
449    set ocidCalendarID to (current application's NSCalendarIdentifierJapanese)
450  else
451    set ocidCalendarID to (current application's NSCalendarIdentifierISO8601)
452  end if
453  set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(ocidCalendarID)
454  set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
455  set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX")
456  ###設定
457  ocidFormatterJP's setTimeZone:(ocidTimezoneJP)
458  ocidFormatterJP's setLocale:(ocidLocaleJP)
459  ocidFormatterJP's setCalendar:(ocidCalendarJP)
460  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterNoStyle)
461  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterShortStyle)
462  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterMediumStyle)
463  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterLongStyle)
464  ocidFormatterJP's setDateStyle:(current application's NSDateFormatterFullStyle)
465  ###渡された値でフォーマット定義
466  ocidFormatterJP's setDateFormat:(strDateFormat)
467  ###フォーマット適応
468  set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidIntervalt)
469  ###テキストで戻す
470  set strDateAndTime to ocidDateAndTime as text
471  return strDateAndTime
472end doGetNextDateNo
473
474
475return "正常終了"
476
AppleScriptで生成しました

|

whのpxサイズ指定でブランクの新規png画像を作成する



ダウンロード - makeblankimage.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004(*
005ダイアログ部ベーススクリプト
006https://www.macscripter.net/t/edit-db123s-dialog-for-use-with-asobjc/73636/2
007
008カラーピッカーはRGBで選んでください
009*)
010#com.cocolog-nifty.quicktimer.icefloe
011----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
012use AppleScript version "2.8"
013use framework "Foundation"
014use framework "UniformTypeIdentifiers"
015use framework "AppKit"
016#use framework "Carbon"
017use scripting additions
018property refMe : a reference to current application
019#
020property appDialogWindow : missing value
021property strOneTextField : missing value
022property strTwoTextField : missing value
023property appCancelButton : missing value
024property appOkButton : missing value
025property strOne : missing value
026property strTwo : missing value
027property appOkClicked : false
028property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
029#画像の保存先 ピクチャー以下
030set appFileManager to refMe's NSFileManager's defaultManager()
031set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask))
032set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
033#TemporaryItemsフォルダ
034set ocidSaveDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("TemporaryItems") isDirectory:(true)
035#なければ作る
036set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
037ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
038set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
039##ダイアログ呼び出し
040set listResponse to doDialoge()
041#縦横サイズ
042set numW to (item 1 of listResponse) as integer
043set numH to (item 2 of listResponse) as integer
044set strDateTime to doGetNextDateNo({"yyyyMMddhhmm", 1})
045set strFileName to (strDateTime & "-" & numW & "x" & numH & "@144") as text
046set ocidSaveBasePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:(false)
047set ocidSaveFilePathURL to ocidSaveBasePathURL's URLByAppendingPathExtension:("png")
048#####
049#カラーピッカー
050set aliasPathToMe to (path to me) as alias
051tell application "Finder"
052  #コンテナ
053  set aliasContainerDirPath to (container of aliasPathToMe) as alias
054  #Swift格納先
055  set aliasBinDirPath to (folder "bin" of folder aliasContainerDirPath) as alias
056  try
057    #binパス
058    set aliasBinPath to (file "launchColorPicker" of folder aliasBinDirPath) as alias
059    set strBinPath to (POSIX path of aliasBinPath) as text
060  on error
061    #Swiftパス バイナリー用 高速
062    # set aliasSwiftPath to (file "launchColorPicker" of folder aliasBinDirPath) as alias
063    #スクリプト 初回だけは遅い
064    set aliasSwiftPath to (file "launchColorPicker.swift" of folder aliasBinDirPath) as alias
065    set strBinPath to (POSIX path of aliasSwiftPath) as text
066  end try
067end tell
068#パス
069set strSwiftPath to (POSIX path of strBinPath) as text
070#コマンド整形 zsh指定
071set strCommandText to ("/bin/zsh -c '" & strSwiftPath & "'") as text
072log strCommandText
073try
074  #コマンド実行
075  set strResponse to (do shell script strCommandText) as text
076end try
077#スペース区切りでリスト化
078set strDelim to AppleScript's text item delimiters
079set AppleScript's text item delimiters to " "
080set listResponse to every text item of strResponse
081set AppleScript's text item delimiters to strDelim
082#数えて
083set numCntList to (count of listResponse) as integer
084##単純にカラーの数で取得
085if (strResponse) contains "Gray" then
086  set numK to (item (numCntList - 1) of listResponse) as number
087  set numA to (item (numCntList) of listResponse) as number
088  set ocidBackgroundColor to (refMe's NSColor's colorWithWhite:(numK) alpha:(numA))
089  
090else if (strResponse) contains "CMYK" then
091  set numC to (item (numCntList - 4) of listResponse) as number
092  set numM to (item (numCntList - 3) of listResponse) as number
093  set numY to (item (numCntList - 2) of listResponse) as number
094  set numK to (item (numCntList - 1) of listResponse) as number
095  set numA to (item (numCntList) of listResponse) as number
096  set ocidBackgroundColor to (refMe's NSColor's colorWithDeviceCyan:(numC) magenta:(numM) yellow:(numY) black:(numK) alpha:(numA))
097else
098  ##それ以外はまぁRGB系でしょう
099  set numR to (item (numCntList - 3) of listResponse) as number
100  set numG to (item (numCntList - 2) of listResponse) as number
101  set numB to (item (numCntList - 1) of listResponse) as number
102  set numA to (item (numCntList) of listResponse) as number
103  set ocidBackgroundColor to (refMe's NSColor's colorWithSRGBRed:(numR) green:(numG) blue:(numB) alpha:(numA))
104end if
105
106
107
108#####
109#カラーICC
110set strIccFilePath to ("/System/Library/ColorSync/Profiles/sRGB Profile.icc") as text
111set ocidIccFilePathStr to refMe's NSString's stringWithString:(strIccFilePath)
112set ocidIccFilePath to ocidIccFilePathStr's stringByStandardizingPath
113set ocidIccFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidIccFilePath) isDirectory:(false)
114set ocidProfileData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidIccFilePathURL)
115#セットするRECT
116set ocidDrawRect to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
117# RGB系のカラースペース
118set ocidColorSpaceName to (refMe's NSCalibratedRGBColorSpace)
119# アルファあり
120set ocidBitmapFormat to (refMe's NSAlphaFirstBitmapFormat)
121#アートボード
122set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numW) pixelsHigh:(numH) bitsPerSample:(8) samplesPerPixel:(4) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(0) bitsPerPixel:(32))
123###########################
124####【NSGraphicsContext's】
125refMe's NSGraphicsContext's saveGraphicsState()
126#Context 選択した画像を読み込んで
127set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
128(ocidSetImageContext's setShouldAntialias:(true))
129(ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
130(ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentRelativeColorimetric))
131#生成された画像でNSGraphicsContext初期化
132(refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
133#マスクパス角丸20PX
134set ocidMaskRect to refMe's NSRect's NSMakeRect(0, 0, numW, numH)
135set ocidMaskPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidDrawRect) xRadius:(20) yRadius:(20)
136ocidMaskPath's addClip()
137#RGB値で背景色をセットして
138ocidBackgroundColor's |set|()
139#指定した色で背景を塗る
140refMe's NSRectFill(ocidDrawRect)
141
142#処理終了
143refMe's NSGraphicsContext's restoreGraphicsState()
144###########################
145#解像度
146set numPPI to 144 as integer
147set numWpt to ((numW / numPPI) * 72) as integer
148set numHpt to ((numH / numPPI) * 72) as integer
149set ocidSetSize to refMe's NSSize's NSMakeSize(numWpt, numHpt)
150ocidArtBoardRep's setSize:(ocidSetSize)
151
152#保存オプション
153set ocidProperty to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
154(ocidProperty's setObject:(refMe's NSNumber's numberWithBool:false) forKey:(refMe's NSImageInterlaced))
155(ocidProperty's setObject:(refMe's NSNumber's numberWithDouble:(1 / 2.2)) forKey:(refMe's NSImageGamma))
156(ocidProperty's setObject:(ocidProfileData) forKey:(refMe's NSImageColorSyncProfileData))
157
158#保存データに変換
159set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidProperty))
160#保存
161set boolDone to (ocidNSInlineData's writeToURL:(ocidSaveFilePathURL) atomically:true)
162###保存先を開く
163set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
164set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
165
166
167##############################
168#####ダイアログ
169##############################
170to doDialoge()
171  tell current application
172    set strName to name as text
173  end tell
174  ####スクリプトメニューから実行したら
175  if strName is "osascript" then
176    tell application "Finder"
177      activate
178    end tell
179  else
180    tell current application
181      activate
182    end tell
183  end if
184  
185  set dialogResult to my doShowDialog()
186  if dialogResult is missing value then
187    return "【エラー】キャンセルしました"
188  end if
189  set strReturnedTextX to strOne of dialogResult
190  set strReturnedTextY to strTwo of dialogResult
191  
192  ##############################
193  #####戻り値整形
194  ##############################
195  set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedTextX))
196  ###タブと改行を除去しておく
197  set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
198  ocidTextM's appendString:(ocidResponseText)
199  ##改行除去
200  set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\n") withString:("")
201  set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\r") withString:("")
202  ##タブ除去
203  set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\t") withString:("")
204  ####戻り値を半角にする
205  set ocidNSStringTransform to (refMe's NSStringTransformFullwidthToHalfwidth)
206  set ocidTextM to (ocidTextM's stringByApplyingTransform:ocidNSStringTransform |reverse|:false)
207  ##カンマ置換
208  set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:(",") withString:(".")
209  ###テキストにしてから
210  set strTextM to ocidTextM as text
211  ###数値に
212  set strReturnedTextX to strTextM as number
213  
214  ###
215  set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedTextY))
216  ###タブと改行を除去しておく
217  set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
218  ocidTextM's appendString:(ocidResponseText)
219  ##改行除去
220  set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\n") withString:("")
221  set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\r") withString:("")
222  ##タブ除去
223  set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\t") withString:("")
224  ####戻り値を半角にする
225  set ocidNSStringTransform to (refMe's NSStringTransformFullwidthToHalfwidth)
226  set ocidTextM to (ocidTextM's stringByApplyingTransform:ocidNSStringTransform |reverse|:false)
227  ##カンマ置換
228  set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:(",") withString:(".")
229  ###数字以外の値を取る
230  #set ocidDecSet to refMe's NSCharacterSet's decimalDigitCharacterSet
231  #set ocidCharSet to ocidDecSet's invertedSet()
232  #set ocidCharArray to ocidResponseHalfwidth's componentsSeparatedByCharactersInSet:ocidCharSet
233  #set ocidInteger to ocidCharArray's componentsJoinedByString:""
234  ###テキストにしてから
235  set strTextM to ocidTextM as text
236  ###数値に
237  set strReturnedTextY to strTextM as number
238  
239  return {strReturnedTextX, strReturnedTextY}
240end doDialoge
241
242####################################
243###### ダイアログ
244####################################
245
246on doShowDialog()
247  if refMe's AEInteractWithUser(-1, missing value, missing value) ≠ 0 then
248    return missing value
249  end if
250  if refMe's NSThread's isMainThread() then
251    my doPerformDialog:(missing value)
252  else
253    its performSelectorOnMainThread:("doPerformDialog:") withObject:(missing value) waitUntilDone:true
254  end if
255  if my appOkClicked then
256    return {strOne:my strOne as text, strTwo:my strTwo as text}
257  end if
258  return missing value
259end doShowDialog
260
261on doPerformDialog:(args)
262  set strOneLabel to refMe's NSTextField's labelWithString:("W px:")
263  strOneLabel's setFrame:(refMe's NSMakeRect(20, 85, 70, 20))
264  
265  set my strOneTextField to refMe's NSTextField's textFieldWithString:""
266  strOneTextField's setFrame:(refMe's NSMakeRect(87, 85, 245, 20))
267  strOneTextField's setEditable:true
268  strOneTextField's setBordered:true
269  strOneTextField's setPlaceholderString:("px数値のみ")
270  strOneTextField's setDelegate:(me)
271  
272  set strTwoLabel to refMe's NSTextField's labelWithString:("H px:")
273  strTwoLabel's setFrame:(refMe's NSMakeRect(20, 55, 70, 20))
274  
275  set my strTwoTextField to refMe's NSTextField's textFieldWithString:("")
276  strTwoTextField's setFrame:(refMe's NSMakeRect(87, 55, 245, 20))
277  strTwoTextField's setEditable:true
278  strTwoTextField's setBordered:true
279  strTwoTextField's setPlaceholderString:("px数値のみ")
280  
281  set my appCancelButton to refMe's NSButton's buttonWithTitle:"Cancel" target:me action:"doButtonAction:"
282  appCancelButton's setFrameSize:{94, 32}
283  appCancelButton's setFrameOrigin:{150, 10}
284  appCancelButton's setKeyEquivalent:(character id 27)
285  
286  set my appOkButton to refMe's NSButton's buttonWithTitle:"OK" target:me action:"doButtonAction:"
287  appOkButton's setFrameSize:{94, 32}
288  appOkButton's setFrameOrigin:{245, 10}
289  appOkButton's setKeyEquivalent:return
290  appOkButton's setEnabled:false
291  
292  set ocidWindowSize to refMe's NSMakeRect(0, 0, 355, 125)
293  set ocidWinStyle to (refMe's NSWindowStyleMaskTitled as integer) + (refMe's NSWindowStyleMaskClosable as integer)
294  set my appDialogWindow to refMe's NSWindow's alloc()'s initWithContentRect:(ocidWindowSize) styleMask:(ocidWinStyle) backing:(refMe's NSBackingStoreBuffered) defer:true
295  
296  appDialogWindow's contentView()'s addSubview:(strOneLabel)
297  appDialogWindow's contentView()'s addSubview:(strOneTextField)
298  appDialogWindow's contentView()'s addSubview:(strTwoLabel)
299  appDialogWindow's contentView()'s addSubview:(strTwoTextField)
300  appDialogWindow's contentView()'s addSubview:(appCancelButton)
301  appDialogWindow's contentView()'s addSubview:(appOkButton)
302  
303  appDialogWindow's setTitle:"ブランク画像生成"
304  appDialogWindow's setLevel:(refMe's NSModalPanelWindowLevel)
305  appDialogWindow's setDelegate:(me)
306  appDialogWindow's orderFront:(me)
307  appDialogWindow's |center|()
308  
309  refMe's NSApp's activateIgnoringOtherApps:true
310  refMe's NSApp's runModalForWindow:(appDialogWindow)
311end doPerformDialog:
312
313on doButtonAction:(sender)
314  if sender is my appOkButton then
315    set my strOne to strOneTextField's stringValue()
316    set my strTwo to strTwoTextField's stringValue()
317    set my appOkClicked to true
318  end if
319  my appDialogWindow's |close|()
320end doButtonAction:
321
322on controlTextDidChange:(objNotification)
323  set sender to objNotification's object()
324  if sender is my strOneTextField then
325    if sender's stringValue() as text"" then
326      my (appOkButton's setEnabled:true)
327    else
328      my (appOkButton's setEnabled:false)
329    end if
330  end if
331end controlTextDidChange:
332
333on windowWillClose:(objNotification)
334  refMe's NSApp's stopModal()
335end windowWillClose:
336
337
338################################
339# 明日の日付 doGetDateNo(argDateFormat,argCalendarNO)
340# argCalendarNO 1 NSCalendarIdentifierGregorian 西暦
341# argCalendarNO 2 NSCalendarIdentifierJapanese 和暦
342################################
343to doGetNextDateNo({argDateFormat, argCalendarNO})
344  ##渡された値をテキストで確定させて
345  set strDateFormat to argDateFormat as text
346  set intCalendarNO to argCalendarNO as integer
347  ###日付情報の取得
348  set ocidDate to current application's NSDate's |date|()
349  set ocidIntervalt to current application's NSDate's dateWithTimeIntervalSinceNow:(86400)
350  ###日付のフォーマットを定義(日本語)
351  set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init()
352  ###和暦 西暦 カレンダー分岐
353  if intCalendarNO = 1 then
354    set ocidCalendarID to (current application's NSCalendarIdentifierGregorian)
355  else if intCalendarNO = 2 then
356    set ocidCalendarID to (current application's NSCalendarIdentifierJapanese)
357  else
358    set ocidCalendarID to (current application's NSCalendarIdentifierISO8601)
359  end if
360  set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(ocidCalendarID)
361  set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
362  set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX")
363  ###設定
364  ocidFormatterJP's setTimeZone:(ocidTimezoneJP)
365  ocidFormatterJP's setLocale:(ocidLocaleJP)
366  ocidFormatterJP's setCalendar:(ocidCalendarJP)
367  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterNoStyle)
368  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterShortStyle)
369  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterMediumStyle)
370  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterLongStyle)
371  ocidFormatterJP's setDateStyle:(current application's NSDateFormatterFullStyle)
372  ###渡された値でフォーマット定義
373  ocidFormatterJP's setDateFormat:(strDateFormat)
374  ###フォーマット適応
375  set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidIntervalt)
376  ###テキストで戻す
377  set strDateAndTime to ocidDateAndTime as text
378  return strDateAndTime
379end doGetNextDateNo
380return
381
AppleScriptで生成しました

|

[自分用]twitter投稿用画像合成(背景色ランダム・文字・角丸・ドロップシャドウ)

こんな画像を生成します
202409040418221080x1080


ダウンロード - makeimagetotwitter.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005# 生成される画像はPNG透過
006#
007#
008----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
009use AppleScript version "2.8"
010use framework "Foundation"
011use framework "AppKit"
012use scripting additions
013property refMe : a reference to current application
014set appFileManager to refMe's NSFileManager's defaultManager()
015
016#############################
017#設定項目 
018#Dataフォルダ内にあるファイルから1つ
019set strRandomColorFileNameRGB to ("PANTONE Plus Pastels and Neons Coated.tsv") as text
020#ロゴマークのファイル 透過で作成 1080x1080pxで四隅なら被らない
021#Templateフォルダに入れておく
022set strLogoMarkFileName to ("LogoMark@1080x1080.png") as text
023
024#############################
025#ダイアログ
026set strName to (name of current application) as text
027if strName is "osascript" then
028  tell application "Finder" to activate
029else
030  tell current application to activate
031end if
032#自分用
033set ocidURLsArray to appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask)
034set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
035
036set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
037set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
038set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
039
040set listUTI to {"public.image"}
041set strMes to ("画像ファイルを選んでください") as text
042set strPrompt to ("画像ファイルを選んでください") as text
043try
044  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
045on error
046  log "エラーしました"
047  return "エラーしました"
048end try
049set strFilePath to (POSIX path of aliasFilePath) as text
050set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
051set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
052set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
053
054#############################
055#カラーICC
056set strIccFilePath to ("/System/Library/ColorSync/Profiles/sRGB Profile.icc") as text
057set ocidIccFilePathStr to refMe's NSString's stringWithString:(strIccFilePath)
058set ocidIccFilePath to ocidIccFilePathStr's stringByStandardizingPath
059set ocidIccFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidIccFilePath) isDirectory:(false)
060set ocidProfileData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidIccFilePathURL)
061#
062set aliasPathToMe to (path to me) as alias
063set strPathToMe to (POSIX path of aliasPathToMe) as text
064set ocidPathToMeStr to refMe's NSString's stringWithString:(strPathToMe)
065set ocidPathToMe to ocidPathToMeStr's stringByStandardizingPath()
066set ocidPathToMeURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidPathToMe) isDirectory:(false)
067set ocidContainerDirPathURL to ocidPathToMeURL's URLByDeletingLastPathComponent()
068#############################
069#PANTONE カラーデータを読み込む
070set strSetPath to ("Data/" & strRandomColorFileNameRGB) as text
071set ocidColorFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strSetPath) isDirectory:(false)
072set listResponse to refMe's NSString's alloc()'s initWithContentsOfURL:(ocidColorFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
073if (item 2 of listResponse) = (missing value) then
074  set ocidReadStrings to (item 1 of listResponse)
075else if (item 2 of listResponse) ≠ (missing value) then
076  set strErrorNO to (item 2 of listResponse)'s code() as text
077  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
078  refMe's NSLog("■:" & strErrorNO & strErrorMes)
079  return "エラーしました" & strErrorNO & strErrorMes
080end if
081#改行をUNIXに強制
082set ocidReadStringsTMP to (ocidReadStrings's stringByReplacingOccurrencesOfString:("\n\r") withString:("\n"))
083set ocidReadStringsTMP to (ocidReadStringsTMP's stringByReplacingOccurrencesOfString:("\r") withString:("\n"))
084set ocidReadStrings to (ocidReadStringsTMP's stringByReplacingOccurrencesOfString:("\n\n") withString:("\n"))
085#文末最後が改行の場合は最後の改行を削除する
086set boolLastReturn to (ocidReadStrings's hasSuffix:("\n")) as boolean
087if boolLastReturn is true then
088  set numStringLength to ocidReadStrings's |length|() as integer
089  set ocidReadStringM to ocidReadStrings's substringToIndex:(numStringLength - 1)
090else
091  set ocidReadStringM to ocidReadStrings
092end if
093#改行区切りでArrayにする
094set ocidColorItemArray to ocidReadStringM's componentsSeparatedByString:("\n")
095#リストの数を数えて
096set numCntArray to (ocidColorItemArray's |count|()) as integer
097#どの色にするか? ランダムの値にする
098set numRandomNO to random number from 0 to (numCntArray - 1)
099#ランダムの値で行データ=リストを取得する
100set ocidLineString to ocidColorItemArray's objectAtIndex:(numRandomNO)
101#タブで各値を格納
102set ocidColorCodeArray to ocidLineString's componentsSeparatedByString:("\t")
103#8BIT カラーの値を 整数に変換
104set str8bitR to (item 2 of ocidColorCodeArray) as text
105set str8bitG to (item 3 of ocidColorCodeArray) as text
106set str8bitB to (item 4 of ocidColorCodeArray) as text
107set ocid8bitR to refMe's NSDecimalNumber's alloc()'s initWithString:(str8bitR)
108set ocid8bitG to refMe's NSDecimalNumber's alloc()'s initWithString:(str8bitG)
109set ocid8bitB to refMe's NSDecimalNumber's alloc()'s initWithString:(str8bitB)
110set ocid8bit to refMe's NSDecimalNumber's alloc()'s initWithString:("255")
111set ocidFloatR to (ocid8bitR's decimalNumberByDividingBy:(ocid8bit))
112set ocidFloatG to (ocid8bitG's decimalNumberByDividingBy:(ocid8bit))
113set ocidFloatB to (ocid8bitB's decimalNumberByDividingBy:(ocid8bit))
114set numFloatR to ocidFloatR's floatValue()
115set numFloatG to ocidFloatG's floatValue()
116set numFloatB to ocidFloatB's floatValue()
117#カラーを定義
118set ocidBackgroundColor to (refMe's NSColor's colorWithSRGBRed:(numFloatR) green:(numFloatG) blue:(numFloatB) alpha:(1.0))
119#色の名前を取得して描画用にStringにしておく
120set strColorName to (item 1 of ocidColorCodeArray) as text
121set ocidText to (refMe's NSString's stringWithString:(strColorName))
122
123#############################
124#画像 選択した画像の 読み込み
125set ocidSetImageFilePathURL to ocidFilePathURL
126#NSDATAに読み込む
127set ocidOption to (refMe's NSDataReadingMappedIfSafe)
128set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidSetImageFilePathURL) options:(ocidOption) |error| :(reference)
129if (item 2 of listResponse) = (missing value) then
130  set ocidSetImageData to (item 1 of listResponse)
131else if (item 2 of listResponse) ≠ (missing value) then
132  set strErrorNO to (item 2 of listResponse)'s code() as text
133  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
134  refMe's NSLog("■:" & strErrorNO & strErrorMes)
135  return "エラーしました" & strErrorNO & strErrorMes
136end if
137#NSIMAGEに
138set ocidSetImageImage to (refMe's NSImage's alloc()'s initWithData:(ocidSetImageData))
139set ocidSetImageImageSize to ocidSetImageImage's |size|()
140set numSetImagePtWidth to ocidSetImageImageSize's width
141set numSetImagePtHeigh to ocidSetImageImageSize's height
142set ocidSetImageFromRect to refMe's NSRect's NSMakeRect(0, 0, numSetImagePtWidth, numSetImagePtHeigh)
143#BitMapRepに変換
144set ocidSetImageRepArray to ocidSetImageImage's representations()
145set ocidSetImageRep to ocidSetImageRepArray's firstObject()
146set numSetImagePixelsWidth to ocidSetImageRep's pixelsWide()
147set numSetImagePixelsHeight to ocidSetImageRep's pixelsHigh()
148#サイズ計算 幅 縦 最大900pxで縦横比を保持する
149if numSetImagePixelsWidth ≥ numSetImagePixelsHeight then
150  set numRatio to (numSetImagePixelsHeight / numSetImagePixelsWidth) as number
151  set numDiffW to (900 - numSetImagePixelsWidth)
152  set numSetW to (numSetImagePixelsWidth + numDiffW) as integer
153  set numSetH to (numSetW * numRatio) as integer
154  set numDiffH to (900 - numSetH) as integer
155else if numSetImagePixelsWidth < numSetImagePixelsHeight then
156  set numRatio to (numSetImagePixelsWidth / numSetImagePixelsHeight) as number
157  set numDiffH to (900 - numSetImagePixelsHeight) as number
158  set numSetH to (numSetImagePixelsHeight + numDiffH) as integer
159  set numSetW to (numSetH * numRatio) as integer
160  set numDiffW to (900 - numSetW) as integer
161end if
162#最終的なDRAWRECTを計算
163set numPasteX to ((1080 - numSetW) / 2) as integer
164set numPasteY to ((1080 - numSetH) / 2) + 52 as integer
165set ocidPasteDrawRect to refMe's NSRect's NSMakeRect(numPasteX, numPasteY, numSetW, numSetH)
166#セットするRECT
167set ocidSetImageDrawRect to refMe's NSRect's NSMakeRect(0, 0, numSetW, numSetH)
168# RGB系のカラースペース
169set ocidColorSpaceName to (refMe's NSCalibratedRGBColorSpace)
170# アルファあり
171set ocidBitmapFormat to (refMe's NSAlphaFirstBitmapFormat)
172#アートボード
173set ocidSetImageArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numSetW) pixelsHigh:(numSetH) bitsPerSample:(8) samplesPerPixel:(4) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(0) bitsPerPixel:(32))
174
175###########################
176####【NSGraphicsContext's】
177refMe's NSGraphicsContext's saveGraphicsState()
178#Context 選択した画像を読み込んで
179set ocidSetImageContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidSetImageArtBoardRep))
180(ocidSetImageContext's setShouldAntialias:(true))
181(ocidSetImageContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
182(ocidSetImageContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentRelativeColorimetric))
183#生成された画像でNSGraphicsContext初期化
184(refMe's NSGraphicsContext's setCurrentContext:(ocidSetImageContext))
185#マスクパス角丸10PX
186set ocidMaskRect to refMe's NSRect's NSMakeRect(0, 0, numSetW, numSetH)
187set ocidMaskPath to refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidSetImageDrawRect) xRadius:(30) yRadius:(30)
188ocidMaskPath's addClip()
189#読み込んだ画像をペースト
190(ocidSetImageRep's drawInRect:(ocidSetImageDrawRect) fromRect:(ocidSetImageFromRect) operation:(refMe's NSCompositingOperationSourceOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
191
192#処理終了
193refMe's NSGraphicsContext's restoreGraphicsState()
194####【NSGraphicsContext's】
195###########################
196#読み込んだ画像の角丸画像↑
197#############################
198#ロゴ画像読み込み
199set strSetLogoFilePath to ("Template/" & strLogoMarkFileName) as text
200set ocidTemplateFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strSetLogoFilePath) isDirectory:(false)
201#NSDATAに読み込む
202set ocidOption to (refMe's NSDataReadingMappedIfSafe)
203set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidTemplateFilePathURL) options:(ocidOption) |error| :(reference)
204if (item 2 of listResponse) = (missing value) then
205  set ocidTemplateData to (item 1 of listResponse)
206else if (item 2 of listResponse) ≠ (missing value) then
207  set strErrorNO to (item 2 of listResponse)'s code() as text
208  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
209  refMe's NSLog("■:" & strErrorNO & strErrorMes)
210  return "エラーしました" & strErrorNO & strErrorMes
211end if
212#NSIMAGEに
213set ocidTemplateImage to (refMe's NSImage's alloc()'s initWithData:(ocidTemplateData))
214set ocidTemplateImageSize to ocidTemplateImage's |size|()
215set numTemplatePtWidth to ocidTemplateImageSize's width
216set numTemplatePtHeigh to ocidTemplateImageSize's height
217#BitMapRepに変換
218set ocidTemplateImageRepArray to ocidTemplateImage's representations()
219set ocidTemplateImageRep to ocidTemplateImageRepArray's firstObject()
220set numPixelsWidth to ocidTemplateImageRep's pixelsWide()
221set numPixelsHeight to ocidTemplateImageRep's pixelsHigh()
222#アートボードになる NSBitmapImageRep
223# RGB系のカラースペース
224set ocidColorSpaceName to (refMe's NSCalibratedRGBColorSpace)
225# アルファあり
226set ocidBitmapFormat to (refMe's NSAlphaFirstBitmapFormat)
227#出力ピクセルサイズのブランクイメージ
228set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numPixelsWidth) pixelsHigh:(numPixelsHeight) bitsPerSample:(8) samplesPerPixel:(4) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(0) bitsPerPixel:(32))
229#アートボード画像にカラープロファイルをエンベッド
230(ocidArtBoardRep's setProperty:(refMe's NSImageColorSyncProfileData) withValue:(ocidProfileData))
231#ArtBord 画像合成用RECT
232set ocidFromRect to refMe's NSRect's NSMakeRect(0, 0, numTemplatePtWidth, numTemplatePtHeigh)
233set ocidDrawRect to refMe's NSRect's NSMakeRect(0, 0, numTemplatePtWidth, numTemplatePtHeigh)
234#ドロップシャドウ初期化
235set ocidSetShadow to refMe's NSShadow's alloc()'s init()
236set ocidOffSetSize to refMe's NSSize's NSMakeSize(10, -20)
237ocidSetShadow's setShadowOffset:(ocidOffSetSize)
238ocidSetShadow's setShadowBlurRadius:(15)
239set ocidShadowColor to refMe's NSColor's colorWithCalibratedWhite:(0.4) alpha:(0.5)
240ocidSetShadow's setShadowColor:(ocidShadowColor)
241
242###########################
243####【NSGraphicsContext's】
244refMe's NSGraphicsContext's saveGraphicsState()
245#Context 無色のアートボードを読み込んで
246set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
247(ocidContext's setShouldAntialias:(true))
248(ocidContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
249(ocidContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentRelativeColorimetric))
250#生成された画像でNSGraphicsContext初期化
251(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
252#背景色を指定する場合
253#set ocidSetColor to (refMe's NSColor's colorWithSRGBRed:(0.937254901961) green:(0.937254901961) blue:(0.937254901961) alpha:(0.0))
254#パントーンで取得したRGB値で背景色をセットして
255ocidBackgroundColor's |set|()
256#指定した色で背景を塗る
257refMe's NSRectFill(ocidDrawRect)
258#ロゴ画像をペースト
259(ocidTemplateImageRep's drawInRect:(ocidDrawRect) fromRect:(ocidFromRect) operation:(refMe's NSCompositingOperationSourceOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
260#シャドウをセットして
261ocidSetShadow's |set|()
262#選択画像のリサイズされた角丸画像をペースト
263(ocidSetImageArtBoardRep's drawInRect:(ocidPasteDrawRect) fromRect:(ocidSetImageDrawRect) operation:(refMe's NSCompositingOperationSourceOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
264
265#画像作成終了
266refMe's NSGraphicsContext's restoreGraphicsState()
267####【NSGraphicsContext's】
268###########################
269
270###フォント初期化
271set appFontManager to refMe's NSFontManager
272set appSharedMaanager to appFontManager's sharedFontManager()
273set ocidTextAttr to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
274set ocidStyle to refMe's NSParagraphStyle's defaultParagraphStyle()
275(ocidTextAttr's setObject:(ocidStyle) forKey:(refMe's NSParagraphStyleAttributeName))
276#テキストカラー黒
277set ocidTextColor to (refMe's NSColor's colorWithSRGBRed:(0) green:(0) blue:(0) alpha:(1.0))
278(ocidTextAttr's setObject:(ocidTextColor) forKey:(refMe's NSForegroundColorAttributeName))
279####【NSGraphicsContext's】
280refMe's NSGraphicsContext's saveGraphicsState()
281set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
282###ArtBoardでNSGraphicsContext初期化
283(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
284#フォント指定
285set ocidFont to (refMe's NSFont's fontWithName:("Helvetica-Bold") |size|:(52))
286(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
287(ocidTextAttr's setObject:(-1.8) forKey:(refMe's NSKernAttributeName))
288set ocidTextOrigin to refMe's NSMakePoint((30), (45))
289#テキストを描画
290(ocidText's drawAtPoint:(ocidTextOrigin) withAttributes:(ocidTextAttr))
291#画像作成終了
292refMe's NSGraphicsContext's restoreGraphicsState()
293####【NSGraphicsContext's】
294###########################
295#保存先
296set ocidSaveDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/PostImage") isDirectory:(true)
297#フォルダ確保
298set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
299ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
300set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
301#ファイル名 上書き防止のため秒数までをファイル名に(安易…笑)
302set strFileName to doGetDateNo("yyyyMMddhhmmss") as text
303set strFileName to (strFileName & "@1080x1080.png")
304set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:(false)
305
306#保存オプション
307set ocidProperty to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
308(ocidProperty's setObject:(refMe's NSNumber's numberWithBool:false) forKey:(refMe's NSImageInterlaced))
309(ocidProperty's setObject:(refMe's NSNumber's numberWithDouble:(1 / 2.2)) forKey:(refMe's NSImageGamma))
310(ocidProperty's setObject:(ocidProfileData) forKey:(refMe's NSImageColorSyncProfileData))
311
312#保存データに変換
313set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidProperty))
314#保存
315set boolDone to (ocidNSInlineData's writeToURL:(ocidSaveFilePathURL) atomically:true)
316
317###保存先を開く
318set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
319set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
320
321
322
323##########################################
324####日付情報の取得
325##########################################
326to doGetDateNo(strDateFormat)
327  ####日付情報の取得
328  set ocidDate to refMe's NSDate's |date|()
329  ###日付のフォーマットを定義
330  set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init()
331  ocidNSDateFormatter's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US")
332  ocidNSDateFormatter's setDateFormat:strDateFormat
333  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
334  set strDateAndTime to ocidDateAndTime as text
335  return strDateAndTime
336end doGetDateNo
AppleScriptで生成しました

|

[NSBezierPath]画像の角を丸める(数値指定ダイアログ)


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005# 画像の角を丸める 角丸 
006# アルファが必要なので保存はPNG専用
007#
008----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
009use AppleScript version "2.8"
010use framework "Foundation"
011use framework "AppKit"
012use scripting additions
013property refMe : a reference to current application
014property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
015
016set appFileManager to refMe's NSFileManager's defaultManager()
017
018######################
019#ファイル選択ダイアログ
020set strName to (name of current application) as text
021if strName is "osascript" then
022  tell application "Finder" to activate
023else
024  tell current application to activate
025end if
026#
027set appFileManager to refMe's NSFileManager's defaultManager()
028set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
029set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
030set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
031#UTIリスト
032set listUTI to {"public.image"}
033set strMes to ("画像ファイルを選んでください") as text
034set strPrompt to ("画像ファイルを選んでください") as text
035try
036  set listAliasFilePath to (choose file strMes with prompt strPrompt default location aliasDefaultLocation of type listUTI with invisibles, multiple selections allowed and showing package contents) as list
037on error
038  log "エラーしました"
039  return "エラーしました"
040end try
041if listAliasFilePath is {} then
042  tell application "Finder"
043    set aliasPathToMe to (path to me) as alias
044  end tell
045  log strPrompt
046  return run script aliasPathToMe
047end if
048
049######################
050#クリップボードの中身取り出し
051set ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
052set ocidPastBoardTypeArray to ocidPasteboard's types
053#テキストがあれば
054set boolContain to ocidPastBoardTypeArray's containsObject:"public.utf8-plain-text"
055if boolContain = true then
056  #値を格納する
057  tell application "Finder"
058    set strReadString to (the clipboard as text) as text
059  end tell
060  #Finderでエラーしたら
061else
062  set boolContain to ocidPastBoardTypeArray's containsObject:"NSStringPboardType"
063  if boolContain = true then
064    set ocidReadString to ocidPasteboard's readObjectsForClasses:({refMe's NSString}) options:(missing value)
065    set strReadString to ocidReadString as text
066  else
067    log "テキストなし"
068    set strReadString to "10" as text
069  end if
070end if
071
072######################
073#ダイアログ
074tell current application
075  set strName to name as text
076end tell
077##スクリプトメニューから実行したら
078if strName is "osascript" then
079  tell application "Finder"
080    activate
081  end tell
082else
083  tell current application
084    activate
085  end tell
086end if
087set aliasIconPath to POSIX file "/System/Applications/Preview.app/Contents/Resources/AppIcon.icns" as alias
088try
089  set recordResult to (display dialog strMes with title "角丸の円の半径をpx値換算で入力してください" default answer strReadString buttons {"OK", "キャンセル"} default button "OK" with icon aliasIconPath giving up after 10 without hidden answer) as record
090on error
091  log "エラーしました"
092  return
093end try
094
095if "OK" is equal to (button returned of recordResult) then
096  set strReturnedText to (text returned of recordResult) as text
097else if (gave up of recordResult) is true then
098  return "時間切れです"
099else
100  return "キャンセル"
101end if
102#NSStringに格納
103set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedText))
104#タブと改行を除去しておく
105set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
106ocidTextM's appendString:(ocidResponseText)
107##改行除去
108set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\n") withString:("")
109set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\r") withString:("")
110##タブ除去
111set ocidTextM to ocidTextM's stringByReplacingOccurrencesOfString:("\t") withString:("")
112##戻り値を半角にする
113set ocidNSStringTransform to (refMe's NSStringTransformFullwidthToHalfwidth)
114set ocidNumText to (ocidTextM's stringByApplyingTransform:ocidNSStringTransform |reverse|:false)
115
116#数字以外があれば中止する
117set ocidDemSet to refMe's NSCharacterSet's characterSetWithCharactersInString:("0123456789.")
118##数字以外って意味で逆セット
119set ocidCharSet to ocidDemSet's invertedSet()
120set ocidOption to (refMe's NSLiteralSearch)
121##数字以外の文字を探して
122set ocidRange to ocidNumText's rangeOfCharacterFromSet:(ocidCharSet) options:(ocidOption)
123set ocidLocation to ocidRange's location
124##なければOK
125if ocidLocation = refNSNotFound then
126  log "処理開始"
127else if ocidLocation0 then
128  tell application "Finder"
129    set aliasPathToMe to (path to me) as alias
130  end tell
131  log "数値以外の値があったのでやりなし"
132  return run script aliasPathToMe
133end if
134##角丸のPX数
135set numRoundPx to (ocidNumText) as integer
136
137####################
138#保存先
139set ocidURLsArray to appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask)
140set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
141set ocidSaveDirPathURL to ocidPicturesDirPathURL's URLByAppendingPathComponent:("TemporaryItems") isDirectory:(true)
142set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
143ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
144set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
145####################
146#カラー
147set strIccFilePath to ("/System/Library/ColorSync/Profiles/sRGB Profile.icc") as text
148set ocidIccFilePathStr to refMe's NSString's stringWithString:(strIccFilePath)
149set ocidIccFilePath to ocidIccFilePathStr's stringByStandardizingPath
150set ocidIccFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidIccFilePath) isDirectory:(false)
151set ocidProfileData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidIccFilePathURL)
152#保存オプション
153set ocidProperty to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
154(ocidProperty's setObject:(refMe's NSNumber's numberWithBool:false) forKey:(refMe's NSImageInterlaced))
155(ocidProperty's setObject:(refMe's NSNumber's numberWithDouble:(1 / 2.2)) forKey:(refMe's NSImageGamma))
156(ocidProperty's setObject:(ocidProfileData) forKey:(refMe's NSImageColorSyncProfileData))
157####################
158#本処理
159#選択したファイルの数だけ繰り返し
160
161repeat with itemAliasFilePath in listAliasFilePath
162  set aliasFilePath to itemAliasFilePath as alias
163  set strFilePath to (POSIX path of aliasFilePath) as text
164  set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
165  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
166  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
167  #ファイル名
168  set ocidFileName to ocidFilePathURL's lastPathComponent()
169  set ocidExtensionName to ocidFileName's pathExtension()
170  set strBaseFileName to ocidFileName's stringByDeletingPathExtension() as text
171  #NSDATAに読み込む
172  set ocidOption to (refMe's NSDataReadingMappedIfSafe)
173  set listResponse to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error| :(reference))
174  if (item 2 of listResponse) = (missing value) then
175    set ocidTemplateData to (item 1 of listResponse)
176  else if (item 2 of listResponse) ≠ (missing value) then
177    set strErrorNO to (item 2 of listResponse)'s code() as text
178    set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
179    refMe's NSLog("■:" & strErrorNO & strErrorMes)
180    return "エラーしました" & strErrorNO & strErrorMes
181  end if
182  #NSIMAGEに
183  set ocidTemplateImage to (refMe's NSImage's alloc()'s initWithData:(ocidTemplateData))
184  set ocidTemplateImageSize to ocidTemplateImage's |size|()
185  set numTemplatePtWidth to ocidTemplateImageSize's width
186  set numTemplatePtHeigh to ocidTemplateImageSize's height
187  #BitMapRepに変換
188  set ocidTemplateImageRepArray to ocidTemplateImage's representations()
189  set ocidTemplateImageRep to ocidTemplateImageRepArray's firstObject()
190  set numPixelsWidth to ocidTemplateImageRep's pixelsWide()
191  set numPixelsHeight to ocidTemplateImageRep's pixelsHigh()
192  #アートボードになる NSBitmapImageRep
193  # RGB系のカラースペース
194  set ocidColorSpaceName to (refMe's NSCalibratedRGBColorSpace)
195  # アルファあり
196  set ocidBitmapFormat to (refMe's NSAlphaFirstBitmapFormat)
197  #出力ピクセルサイズのブランクイメージ
198  set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numPixelsWidth) pixelsHigh:(numPixelsHeight) bitsPerSample:(8) samplesPerPixel:(4) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(0) bitsPerPixel:(32))
199  #アートボード画像にカラープロファイルをエンベッド
200  (ocidArtBoardRep's setProperty:(refMe's NSImageColorSyncProfileData) withValue:(ocidProfileData))
201  
202  #ArtBord 画像合成
203  set ocidFromRect to refMe's NSRect's NSMakeRect(0, 0, numTemplatePtWidth, numTemplatePtHeigh)
204  set ocidDrawRect to refMe's NSRect's NSMakeRect(0, 0, numTemplatePtWidth, numTemplatePtHeigh)
205  
206  #### 初期化 saveGraphicsState
207  refMe's NSGraphicsContext's saveGraphicsState()
208  #Context
209  set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
210  (ocidContext's setShouldAntialias:(true))
211  (ocidContext's setImageInterpolation:(refMe's NSImageInterpolationHigh))
212  (ocidContext's setColorRenderingIntent:(refMe's NSColorRenderingIntentRelativeColorimetric))
213  #生成された画像でNSGraphicsContext初期化
214  (refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
215  #背景色を指定(透過させないため)
216  # set ocidSetColor to (refMe's NSColor's colorWithSRGBRed:(1.0) green:(1.0) blue:(1.0) alpha:(0.0))
217  #ocidSetColor's |set|()
218  #指定した色で背景を塗る
219  #refMe's NSRectFill(ocidDrawRect)
220  ####################
221  #マスクパス角丸10PX
222  set ocidMaskPath to (refMe's NSBezierPath's bezierPathWithRoundedRect:(ocidFromRect) xRadius:(numRoundPx) yRadius:(numRoundPx))
223  ocidMaskPath's addClip()
224  #元画像を描画
225  (ocidTemplateImageRep's drawInRect:(ocidDrawRect) fromRect:(ocidFromRect) operation:(refMe's NSCompositingOperationSourceOver) fraction:(1.0) respectFlipped:(false) hints:(missing value))
226  #画像作成終了
227  refMe's NSGraphicsContext's restoreGraphicsState()
228  #保存ファイル名
229  set strSaveFileName to (strBaseFileName & "@" & (numPixelsWidth as text) & "x" & numPixelsHeight & ".rounded")
230  #保存パス
231  set ocidSaveBaseFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName) isDirectory:(false))
232  set ocidSaveFilePathURL to (ocidSaveBaseFilePathURL's URLByAppendingPathExtension:("png"))
233  #変換
234  set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidProperty))
235  #保存
236  set ocidOption to (refMe's NSDataWritingAtomic)
237  set listDone to (ocidNSInlineData's writeToURL:(ocidSaveFilePathURL) options:(ocidOption) |error| :(reference))
238  if (item 1 of listDone) is true then
239    log "正常処理"
240  else if (item 2 of listDone) ≠ (missing value) then
241    set strErrorNO to (item 2 of listDone)'s code() as text
242    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
243    refMe's NSLog("■:" & strErrorNO & strErrorMes)
244    return "エラーしました" & strErrorNO & strErrorMes
245  end if
246  
247end repeat
248
249#保存先を開く
250set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
251set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
252
253return
AppleScriptで生成しました

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat Python Acrobat Reader Acrobat Reader Localized Acrobat Reference Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Admin XProtect Adobe Adobe Bridge Adobe FDKO Adobe Fonts Adobe Reference Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode Decode Barcode QR Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time defaults delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode HTML Entity Encode UTF8 Error EXIFData ffmpeg File File Name Finder Firefox Folder FolderAction Fonts Fonts ATS Fonts Python Foxit GIF github Guide HTML Icon Illustrator Image Events Image2PDF ImageOptim Input Dictionary iPhone iWork Javascript Jedit Json Label Language Leading Zero List locationd LRC lsappinfo m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Microsoft Fonts Microsoft Office Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMetadataItem NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDF Pymupdf PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline PDFView perl Photoshop PlistBuddy pluginkit plutil postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML HTML XML LSSharedFileList XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML xmllint XML XMP YouTube zoom