Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

カテゴリー: file

iBooksライブラリ中のepubファイルから情報を取得 v3

Posted on 2月 13, 2018 by Takaaki Naganoya
AppleScript名:iBooksライブラリ中のepubファイルから情報を取得 v3
— Created 2017/02/26 by Christopher Stone
— Modified 2017/11/01 by Takaaki Naganoya
use framework "Foundation"
use scripting additions
use mdLib : script "Metadata Lib" version "1.0.0" –https://www.macosxautomation.com/applescript/apps/Script_Libs.html#Metadata_Lib

property NSString : a reference to current application’s NSString
property NSMutableArray : a reference to current application’s NSMutableArray
property NSPropertyListFormat : a reference to current application’s NSPropertyListFormat
property NSUTF8StringEncoding : a reference to current application’s NSUTF8StringEncoding
property NSPropertyListImmutable : a reference to current application’s NSPropertyListImmutable
property NSPropertyListSerialization : a reference to current application’s NSPropertyListSerialization

set aPath to POSIX path of (path to library folder from user domain)
set sourceFolder to aPath & "Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books/"

set textFiles to mdLib’s searchFolders:{sourceFolder} searchString:"kMDItemContentType contains %@ || kMDItemContentType contains %@ " searchArgs:{"com.apple.ibooks-folder", "org.idpf.epub-container"}

set outDicList to NSMutableArray’s new()
repeat with i in textFiles
  set aFile to (i as string)
  
  
if aFile ends with "/" then
    set aFullPath to aFile & "iTunesMetadata.plist"
  else
    set aFullPath to aFile & "/iTunesMetadata.plist"
  end if
  
  
try
    set xmlData to read ((POSIX file aFullPath) as alias) as «class utf8»
    
set xRes to readPlistFromStr(xmlData) of me
    
log xRes as list of string or string –as anything (maybe record or missing value)
    
    
(*cover-writing-mode:vertical, genre:教育, scroll-axis:default, sort-artist:あっぷる, BKITunesMigratedMetadata:PersistentID:6.68315366592803E+18, seriesTitle:Everyone Can Code, sort-name:Swiftによるあぷりけーしょん開発:入門編, itemId:1209648719, apple-id:xxxxxxxxxxxx@xxx.xxx, fileExtension:ibooks, year:2017, releaseDate:2017-03-19T07:00:00Z, BKInsertionDate:512115887, asset-info:flavor:pluspub, file-size:60642970, book-info:publication-version:162901775, PageProgression:default, asset-info:flavor:pluspub, file-size:60642970, package-file-hash:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, BKAllocatedSize:82993152, longDescription:このコースでは、Swiftという言語を使って基本的なプログラミングの土台をしっかりと作り上げていきます。基本的なiOSアプリケーションを一から開発するために必要なツール、手法、概念を活用して、実践的な練習に取り組みます。さらに、プログラミングと優れたアプリケーション開発の土台となる、ユーザーインターフェイス設計の基本原則についても学習します。このコースを受講するにあたってプログラミングの経験は必要ありません。プログラミングの経験がある場合、レッスンの最初の方は簡単に読み進めていただくとよいでしょう。このブックではプログラミングの基礎にとどまらず、ソフトウェア開発ツールや概念、ベストプラクティスについても学習できます。, artistId:9.39801385E+8, artistName:Apple Education, isPreview:false, BKDisplayName:mzbf.eqmpijqw..d2.dlv.d2.dlv.ibooks, human-friendly-publication-version:1.1, shouldDisableTouchEmulation:true, vendorId:379015, drmVersionNumber:0, kind:ebook, s:143462, genreId:10037, explicit:2, seriesAdamId:1.118575554E+9, publisher:Apple Inc. – Education, versionRestrictions:16843008, BKGenerationCount:2, desktopSupportLevel:supported, primaryLanguage:ja, itemName:Swiftによるアプリケーション開発:入門編, purchaseDate:2017-03-25T06:21:26Z, shouldDisableOptimizeSpeed:true, obeyPageBreaks:1, pageCount:244*)
    
if xRes is not equal to missing value then
      (outDicList’s addObject:xRes)
    end if
  end try
end repeat

return outDicList as list of string or string –as anything

–stringのplistを読み込んでNSDictionaryに
on readPlistFromStr(theString)
  set aSource to NSString’s stringWithString:theString
  
set pListData to aSource’s dataUsingEncoding:(NSUTF8StringEncoding)
  
set aPlist to NSPropertyListSerialization’s propertyListFromData:pListData mutabilityOption:(NSPropertyListImmutable) |format|:(NSPropertyListFormat) errorDescription:(missing value)
  
return aPlist
end readPlistFromStr

★Click Here to Open This Script 

Posted in file System | Tagged 10.11savvy 10.12savvy 10.13savvy iBooks | Leave a comment

画像を文字認識して文字エリアを塗りつぶし v3

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image(CIColorMonochrome)


▲Filtered Image(CIColorPosterize)


▲Result Image

AppleScript名:画像を文字認識して文字エリアを塗りつぶし v3
— Created 2017-11-19 by Takaaki Naganoya
— Modified 2018-02-11 by Takaaki Naganoya
–v3:画像の前処理を付加
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "QuartzCore"
use framework "AppKit"

set retinaF to (current application’s NSScreen’s mainScreen()’s backingScaleFactor()) as real
–>  2.0 (Retina) / 1.0 (Non Retina)

set imgPath to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:imgPath
set aCIImage to convNSImageToCIimage(anImage)

–モノクロ化フィルタ
set bCIImage to monochromefilterACGImage(aCIImage) of me

–2階調ポスタライズフィルタ
set cCIImage to posterizefilterACGImage(bCIImage) of me

–文字領域認識
set detectList to textDetect(cCIImage) of me

–描画開始
anImage’s lockFocus()

repeat with i in detectList
  set origX to (x of origin of i) / retinaF
  
set origY to (y of origin of i) / retinaF
  
set sizeX to (width of |size| of i) / retinaF
  
set sizeY to (height of |size| of i) / retinaF
  
  
set theRect to {{x:origX, y:origY}, {width:sizeX, height:sizeY}}
  
  
set theNSBezierPath to current application’s NSBezierPath’s bezierPath
  (
theNSBezierPath’s appendBezierPathWithRect:theRect)
  
  
set rRnd to (random number from 1 to 10) / 10
  
set gRnd to (random number from 1 to 10) / 10
  
set bRnd to (random number from 1 to 10) / 10
  
set fillColor to (current application’s NSColor’s colorWithCalibratedRed:rRnd green:gRnd blue:bRnd alpha:0.6)
  
  
fillColor’s |set|() –色設定
  
theNSBezierPath’s fill() –ぬりつぶし
end repeat

anImage’s unlockFocus()
–描画ここまで

set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:imgPath)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"

set fRes to saveImageRepAtPathAsPNG(anImage, aPath) of me

on openImageFile(imageFile) — imageFile: POSIX path 形式のファイルパス
  set fileURL to current application’s |NSURL|’s fileURLWithPath:imageFile
  
return current application’s CIImage’s alloc()’s initWithContentsOfURL:fileURL
end openImageFile

–画像を指定パスにPNG形式で保存
on saveImageRepAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
–書き出しファイルパス情報を作成
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
–書き出し
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
return (myNewImageData’s writeToFile:newPath atomically:true) as boolean
end saveImageRepAtPathAsPNG

on textDetect(imageRef)
  — 検出器のオプションを NSDictonary で作成
  
set optDic1 to current application’s NSDictionary’s dictionaryWithObject:(current application’s CIDetectorAccuracyHigh) forKey:(current application’s CIDetectorAccuracy)
  
set textDetector to current application’s CIDetector’s detectorOfType:(current application’s CIDetectorTypeText) context:(missing value) options:optDic1
  
  
— 文字エリア検出を実行
  
set optDic2 to current application’s NSDictionary’s dictionaryWithObject:true forKey:(current application’s CIDetectorReturnSubFeatures)
  
set textArray to textDetector’s featuresInImage:imageRef options:optDic2
  
  
set fList to {}
  
  
— 検出されたテキストの位置とサイズをログに出力
  
repeat with i from 1 to (count of textArray)
    set typeFace to item i of textArray
    
set bList to (typeFace’s subFeatures())
    
    
repeat with ii in bList
      set aBounds to ii’s |bounds|()
      
set aType to ii’s type()
      
set the end of fList to aBounds
    end repeat
    
  end repeat
  
  
return fList
  
end textDetect

on convCIimageToNSImage(aCIImage)
  set aRep to current application’s NSBitmapImageRep’s alloc()’s initWithCIImage:aCIImage
  
set tmpSize to aRep’s |size|()
  
set newImg to current application’s NSImage’s alloc()’s initWithSize:tmpSize
  
newImg’s addRepresentation:aRep
  
return newImg
end convCIimageToNSImage

on convNSImageToCIimage(aNSImage)
  set tiffDat to aNSImage’s TIFFRepresentation()
  
set aRep to current application’s NSBitmapImageRep’s imageRepWithData:tiffDat
  
set newImg to current application’s CIImage’s alloc()’s initWithBitmapImageRep:aRep
  
return newImg
end convNSImageToCIimage

–Posterizeフィルタ
on posterizefilterACGImage(aCIImage)
  set aFilter to current application’s CIFilter’s filterWithName:"CIColorPosterize"
  
aFilter’s setDefaults()
  
  
aFilter’s setValue:aCIImage forKey:"inputImage"
  
aFilter’s setValue:2 forKey:"inputLevels"
  
  
set aOutImage to aFilter’s valueForKey:"outputImage"
  
return aOutImage
end posterizefilterACGImage

–Monochromeフィルタ
on monochromefilterACGImage(aCIImage)
  set aFilter to current application’s CIFilter’s filterWithName:"CIColorMonochrome"
  
aFilter’s setDefaults()
  
  
aFilter’s setValue:aCIImage forKey:"inputImage"
  
aFilter’s setValue:1.0 forKey:"inputIntensity"
  
  
set aOutImage to aFilter’s valueForKey:"outputImage"
  
return aOutImage
end monochromefilterACGImage

★Click Here to Open This Script 

Posted in file Image Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

JPEG画像の破損チェック

Posted on 2月 11, 2018 by Takaaki Naganoya

かつて、破損JPEG画像はアプリケーションのクラッシュを引き起こすケースもあり、Mac OS Xでもなかなか細心の注意をはらって事前のチェックを行なっていました(Mac OS X 10.4のころ)。

AppleScriptによるバッチ処理では、大量のデータを相手にします。そのため、途中でエラーを発生させるようなイレギュラーなデータにはエラートラップを仕掛けてあらかじめ対処しておきますが、クラッシュを引き起こすような破損データについては事前に手の施しようがありません。

# 破損画像によるクラッシュが発生して処理が停止するトラブルに直面したときには、入稿データの添付画像の破損チェックを自動で行うようにして対処しました。そもそも破損していては話にならないので

この破損画像が引き起こすクラッシュは(iOSの方で)クラッカーからの格好の標的にされたため(初期の「脱獄」の手口がこの破損画像にともなうクラッシュ→実行権限乗っ取りでした)、対策がすすみ、iOSと共通基盤を持っているMac OS Xでも同様の対策が行われたためか、Mac OS X→OS X→macOSと呼称が変わるにつれて徐々にクラッシュしないように強化されてきた機能でもあります。

今日、破損画像にそれほど神経質にならなくても済むようになっていますが、古いOSを使い続けている環境がないわけではありません。そうした環境においては、画像処理前の破損画像のチェックは重要な処理であり続けることでしょう。

また、巨大な画像データを遅い回線/サーバー経由でダウンロードして処理する場合には、「念のため」チェックを行なっておくべきかもしれません。

本ScriptのようにJPEGマーカーの有無をチェックするのは、破損画像検出の手口としては入門レベルであり、画像処理を行うプログラムで実際に読み込み+表示+書き出しを行わせるぐらいの処理をしておく必要があります(読み込めて表示できても、書き出しができない破損画像にも遭遇しました)。

実際にさまざまな現場で集めた「破損画像」は、大切に自分の手元に集めてあります。

AppleScript名:JPEG画像の破損チェック
— Created 2006-10-17 by Somebody
— Modified 2015-10-06 by Takaaki Naganoya

set aFile to choose file of type {"public.jpeg"}
set dRes to VerifyCompleteJPEG(aFile) of me

— to verify whether a JPEG is a111 full or partial (e.g. partially downloaded) JPEG
— last two JPEG file bytes must be (ASCII character 255) & (ASCII character 217)
on VerifyCompleteJPEG(f)
  try
    set s to read f from -2 for 2
  on error
    return false –error "JPEG image is too short or currupted"
  end try
  
  
if s = (ASCII character 255) & (ASCII character 217) then
    return true
  else
    return false
  end if
end VerifyCompleteJPEG

★Click Here to Open This Script 

Posted in file Image | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像の破損チェック v2

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:画像の破損チェック v2
set theFile to choose file
set aRes to breakImageCheck(theFile) of me
–> true / false

–破損画像チェック
–(通常時:true、破損時:false が返ってくる)
–対象形式:PICT/Photoshop/BMP/QuickTime Image/GIF/JPEG/MacPaint/JPEG2/SGI/PSD/TGA/Text/PDF/PNG/TIFF
on breakImageCheck(theFile)
  try
    tell application "Image Events"
      set {theWidth, theHeight} to dimensions of image theFile
    end tell
    
return true –normal image
  on error
    return false –broken image
  end try
end breakImageCheck

★Click Here to Open This Script 

macOS 10.14、10.15向けに修正。ただし、macOS 10.15ではデフォルト設定のままだとImage Eventsがユーザーディレクトリ以下のファイルにアクセスできない状態で出荷されているため、システム環境設定の「セキュリティとプライバシー」>「セキュリティ」>「フルディスクアクセス」に登録しておく必要があります。

AppleScript名:画像の破損チェック v2b.scpt
set theFile to (choose file of type {"public.image"}) as «class furl»
set aRes to breakImageCheck(theFile) of me
–> true / false

–破損画像チェック
–(通常時:true、破損時:false が返ってくる)
–対象形式:PICT/Photoshop/BMP/QuickTime Image/GIF/JPEG/MacPaint/JPEG2/SGI/PSD/TGA/Text/PDF/PNG/TIFF
on breakImageCheck(theFile)
  try
    tell application "Image Events"
      set tmpImage to open theFile
      
set aProp to properties of tmpImage
      
close tmpImage
    end tell
    
return true –normal image
  on error
    return false –broken image
  end try
end breakImageCheck

★Click Here to Open This Script 

Posted in file Image | Tagged 10.11savvy 10.12savvy 10.13savvy 10.14savvy 10.15savvy Image Events | Leave a comment

画像の破損チェック

Posted on 2月 11, 2018 by Takaaki Naganoya

画像の破損チェックを行うAppleScriptです。

昔、Mac OS X 10.3や10.4の時代には、破損画像をオープンするとアプリケーションごとクラッシュすることがありました。そのため、アプリケーションのクラッシュを伴うような「破損画像」のチェックを行うことには意味がありました。

その後、Mac OS XからOS Xへと名称が変更になったあたりで、共通の基盤を持っているiOSのクラッシュ対策がフィードバックされたためか、こうした破損画像に対する耐性が高まりました(OS X 10.7ぐらい?)。

画像の破損は、①オープン時にワーニングメッセージが出るレベル、②画像として読み込んでムービー書き出し時に問題の出るレベル、③そもそも全破損していてオープンすらできないレベル、に個人的に区分けしており、本ルーチンでは③に対してエラーを出しつつも、①と②についてはOSの進歩とともに問題になりにくくなっている(エラー検出できない)状態です。

AppleScriptの穴Blogアーカイブ本Vol.5において、「EPSファイルの破損チェック(高速版)」を収録しています。

AppleScript名:画像の破損チェック
— Created 2016-08-24 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

set aPath to (choose file of type {"public.image"})
set aRes to confirmImage(aPath) of me

–画像の破損チェック(can not open画像はチェックOK) 破損時にはfalseを返す
on confirmImage(aPath)
  set aType to type identifier of (info for aPath)
  
set aPOSIX to POSIX path of aPath
  
  
set aImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aPOSIX
  
if aImage = missing value then return {false, aType, 1}
  
  
set aRes to aImage’s isValid()
  
return {aRes, aType, 2}
end confirmImage

★Click Here to Open This Script 

Posted in file Image | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

指定画像の明度ヒストグラム画像を出力する

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:指定画像の明度ヒストグラム画像を出力する
— Created 2017-02-12 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

set aFile to POSIX path of (choose file of type {"public.image"} with prompt "Select a Image to check it is white (or not) ")
set anNSImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile
set wRes to getHistogramFromImage(anNSImage, 4) of me

set aPath to (POSIX path of (path to desktop) & (current application’s NSUUID’s UUID())’s UUIDString() as string) & ".png"
set fRes to saveNSImageAtPathAsPNG(wRes, aPath) of me

–指定のNSImageをGPUImage.frameworkで明度ヒストグラム化してNSImageで返す
on getHistogramFromImage(aNSImage, histogramType)
  set aFilter to current application’s GPUImageHistogramFilter’s alloc()’s initWithHistogramType:histogramType
  
set aProcImg to (aFilter’s imageByFilteringImage:aNSImage)
  
return aProcImg
end getHistogramFromImage

–NSImageをGPUImage.frameworkの指定フィルタで処理してNSImageを返す
on filterWithNSImage(aNSImage, filterName as string)
  set aClass to current application’s NSClassFromString(filterName)
  
set aImageFilter to aClass’s alloc()’s init()
  
set aProcImg to (aImageFilter’s imageByFilteringImage:aNSImage)
  
return aProcImg
end filterWithNSImage

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にHistogramGeneratorを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にHistogramGeneratorを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageHistogramGenerator’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にGaussianBlurFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にGaussianBlurFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageGaussianBlurFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にUnsharpMaskFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にUnsharpMaskFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageUnsharpMaskFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にSharpenFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にSharpenFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageSharpenFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にFalseColorFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にFalseColorFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageFalseColorFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にKuwaharaFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にKuwaharaFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageKuwaharaFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にGrayscaleFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にGrayscaleFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageGrayscaleFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にToonFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にToonFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageToonFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にSketchFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にSketchFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageSketchFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にSobelEdgeDetectionFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にSobelEdgeDetectionFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageSobelEdgeDetectionFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にMonochromeFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にMonochromeFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageMonochromeFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

画像にSepiaFilterを実行してデスクトップにPNG形式で保存

Posted on 2月 11, 2018 by Takaaki Naganoya


▲Original Image


▲Filtered Image

–> GPUImage.framework

AppleScript名:画像にSepiaFilterを実行してデスクトップにPNG形式で保存.scptd
— Created 2017-02-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "GPUImage" –https://github.com/BradLarson/GPUImage

–Read JPEG file
set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile

–Filter Image
set stillImageFilter to current application’s GPUImageSepiaFilter’s alloc()’s init()
set aProcImg to stillImageFilter’s imageByFilteringImage:anImage

–Make New File Name
set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string
set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png"
set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes –true/false
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in file filter UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

AIFFをM4aに変換する

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:AIFFをM4aに変換する
— Created 2016-10-24 by Shane Stanley
use AppleScript version "2.4"
use framework "Foundation"
use framework "AVFoundation"
use scripting additions

set posixPath to POSIX path of (choose file with prompt "Choose an AIFF file:" of type {"public.aifc-audio"})
my convertAIFFToM4aAt:posixPath deleteOriginal:false

on convertAIFFToM4aAt:posixPath deleteOriginal:deleteFlag
  set theURL to current application’s |NSURL|’s fileURLWithPath:posixPath
  
  
— set destination to use same path, different extension
  
set destURL to theURL’s URLByDeletingPathExtension()’s URLByAppendingPathExtension:"m4a"
  
set theAsset to current application’s AVAsset’s assetWithURL:theURL
  
  
— check asset can be converted
  
set allowedPresets to current application’s AVAssetExportSession’s exportPresetsCompatibleWithAsset:theAsset
  
if (allowedPresets’s containsObject:(current application’s AVAssetExportPresetAppleM4A)) as boolean is false then
    error "Can’t export this file as an .m4a file."
  end if
  
  
— set up export session
  
set theSession to current application’s AVAssetExportSession’s exportSessionWithAsset:theAsset presetName:(current application’s AVAssetExportPresetAppleM4A)
  
theSession’s setOutputFileType:(current application’s AVFileTypeAppleM4A)
  
theSession’s setOutputURL:destURL
  
  
— begin export and poll for completion
  
theSession’s exportAsynchronouslyWithCompletionHandler:(missing value)
  
repeat
    set theStatus to theSession’s status() as integer
    
if theStatus < 3 then
      delay 0.2
    else
      exit repeat
    end if
  end repeat
  
  
— throw error if it failed
  
if theStatus = (current application’s AVAssetExportSessionStatusFailed) as integer then
    error (theSession’s |error|()’s localizedDescription() as text)
  end if
  
  
— delete original if required
  
if deleteFlag then
    current application’s NSFileManager’s defaultManager()’s removeItemAtURL:theURL |error|:(missing value)
  end if
end convertAIFFToM4aAt:deleteOriginal:

★Click Here to Open This Script 

Posted in file UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

ムービー系の拡張子からFile Format UTIを取得する v3

Posted on 2月 11, 2018 by Takaaki Naganoya
AppleScript名:ムービー系の拡張子からFile Format UTIを取得する v3
— Created 2016-10-24 by Takaaki Naganoya
— Modified 2016-10-25 by Shane Stanley
— 2016 Piyomaru Software
use AppleScript version "2.4"
use framework "Foundation"
use framework "AVFoundation"
use scripting additions
use BridgePlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

set aRes to retFileFormatUTI("mov") of me
–>   "com.apple.quicktime-movie"

set aRes to retFileFormatUTI("mp4") of me
–>   "public.mpeg-4"

set aRes to retFileFormatUTI("m4v") of me
–>   "com.apple.m4v-video"

set aRes to retFileFormatUTI("m4a") of me
–>   "com.apple.m4a-audio"

set aRes to retFileFormatUTI("3gp") of me
–>   "public.3gpp"

set aRes to retFileFormatUTI("3gp2") of me
–>   "public.3gpp2"

set aRes to retFileFormatUTI("caf") of me
–>   "com.apple.coreaudio-format"

set aRes to retFileFormatUTI("wav") of me
–>   "com.microsoft.waveform-audio"

set aRes to retFileFormatUTI("aif") of me
–>   "public.aifc-audio"

set aRes to retFileFormatUTI("aifc") of me
–>   "public.aifc-audio"

set aRes to retFileFormatUTI("amr") of me
–>   "org.3gpp.adaptive-multi-rate-audio"

set aRes to retFileFormatUTI("mp3") of me
–>   "public.mp3"

set aRes to retFileFormatUTI("au") of me
–>   "public.au-audio"

set aRes to retFileFormatUTI("ac3") of me
–>   "public.ac3-audio"

on retFileFormatUTI(aExt as string)
  load framework
  
return (current application’s SMSForder’s UTIForExtension:aExt) as string
end retFileFormatUTI

★Click Here to Open This Script 

Posted in file UTI | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Post navigation

  • Older posts
  • Newer posts

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • CotEditorで2つの書類の行単位での差分検出
  • macOS 13.6.5 AS系のバグ、一切直らず
  • macOS 15, Sequoia
  • 初心者がつまづきやすい「log」コマンド
  • 指定のWordファイルをPDFに書き出す
  • Pages本執筆中に、2つの書類モード切り替えに気がついた
  • Adobe AcrobatをAppleScriptから操作してPDF圧縮
  • メキシカンハットの描画
  • 与えられた文字列の1D Listのすべての順列組み合わせパターン文字列を返す v3(ベンチマーク用)
  • 2023年に書いた価値あるAppleScript
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • Numbersで選択範囲のセルの前後の空白を削除
  • AdobeがInDesign v19.4からPOSIX pathを採用
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • Cocoa Scripting Course 続刊計画
  • AppleScriptによる並列処理
  • macOS 14.xでScript Menuの実行速度が大幅に下がるバグ
  • NaturalLanguage.frameworkでNLEmbeddingの処理が可能な言語をチェック
  • AppleScript入門③AppleScriptを使った「自動化」とは?

Tags

10.11savvy (1102) 10.12savvy (1243) 10.13savvy (1392) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (212) 13.0savvy (188) 14.0savvy (138) 15.0savvy (116) CotEditor (64) Finder (51) iTunes (19) Keynote (115) NSAlert (61) NSArray (51) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (53) NSDictionary (28) NSFileManager (23) NSFont (21) NSImage (41) NSJSONSerialization (21) NSMutableArray (63) NSMutableDictionary (22) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (119) NSURL (98) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (75) Pages (54) Safari (44) Script Editor (27) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • Beginner
  • Benchmark
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • check sum
  • Clipboard
  • Cocoa-AppleScript Applet
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • diff
  • drive
  • Droplet
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Localize
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • parallel processing
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2025年2月
  • 2025年1月
  • 2024年12月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2024年2月
  • 2024年1月
  • 2023年12月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC