AppleScript Photos

アニメーション画像

アニメーション画像
(各種WEBサービスを利用しない場合)
A:gif
B:APNG (Animated png)
C:Animated webp
D:Movie
E:マルチページPNG



ツール類
A:gif
[bash]gifskiインストール
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-724851.html
デスクトップアプリ版
https://github.com/sindresorhus/Gifski?tab=readme-ov-file#download
AppStore版
https://apps.apple.com/us/app/gifski/id1351639930?mt=12


B:APNG (Animated png)
デスクトップ版
https://github.com/shgodoroja/APNGb



C:Animated webp
[applescript]libwebpインストール
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-0a1a86.html
[bash]libwebpインストール
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-84a951.html


D:Movie
Shutter Encoderからffmpegの取り出し
https://quicktimer.cocolog-nifty.com/icefloe/2024/02/post-61c3e2.html
[AppleScript]ffmpegインストール(野良)
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-1ce12f.html
[Bash]ffmpegインストール
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-c0e627.html


E:マルチページPNG
[Combined Merged PNG]マルチレイヤ構造のPNG画像を個別のファイルにする
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-bf44c9.html
[Combined Merged PNG]マルチレイヤ構造のPNG画像をGIFアニメに変換する(簡易版)
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-89705d.html


処理

1:Image to GIf
[gifski]イメージシーケンスをGIFにする
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-2ba1ab.html
2:Image to apng
APNGbデスクトップ版
https://github.com/shgodoroja/APNGb
3:Image to webp
[img2webp]アニメーションwebpの作成
https://quicktimer.cocolog-nifty.com/icefloe/2022/12/post-aa3e08.html
4:Image to movie
[QuickTime]イメージシーケンス(複数画像)からムービーを作成する
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-383ed1.html



A:gif
1:GIF to Image
[Gif]gifアニメーションの各コマを別ファイルに保存(イメージシーケンス保存)
https://quicktimer.cocolog-nifty.com/icefloe/2023/05/post-4c0c6b.html
2:GIF to Movie
[ffmpeg] GIFアニメーションをmp4に変換する
https://quicktimer.cocolog-nifty.com/icefloe/2023/10/post-154f42.html
3:GIF to webp
[gif2webp]GIFアニメをwebpに変換する
https://quicktimer.cocolog-nifty.com/icefloe/2022/12/post-c8af28.html


B:APNG (Animated png)
1:apng to movie
2:apng to image


C:Animated webp
1:webp to image
[webpmux] アニメーションWEBPファイルから各フレームイメージを書き出す(差分イメージ)
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-0643c2.html
[anim_dump] アニメーションWEBPファイルから各フレームイメージを書き出す(フレームイメージ)
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-ccfea9.html
2:webp to Movie
イメージシーケンスを書き出して[LINK]から イメージシーケンスをムービーに変換
3:webp to Gif
イメージシーケンスを書き出して[LINK]から GIFにする


D:Movie
1:Movie to Image
[ffmpeg]ムービーファイルをイメージシーケンス画像にする
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-176cb7.html
2:Movie to Gif
[ffmpeg]ムービーファイルをGIFにする
https://quicktimer.cocolog-nifty.com/icefloe/2023/11/post-a1c3d2.html
[gifski]ムービーファイルをGIFにする
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-555b0a.html
[gifski]デスクトップアプリ版
https://github.com/sindresorhus/Gifski?tab=readme-ov-file#download
3:Movie to webp
3−1:ムービーフレームをイメージシーケンス画像に書き出してから img2webpで変換
3−2:ムービーファイルをgifski等でGIFアニメにしてから gif2webp
3−3:ffmpegで変換
[ffmpeg]ムービーファイルをアニメーションwebpにする
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-3519c3.html

|

[写真.app]基本

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#error number -128
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL



###パス関連
set aliasPicturesPath to (path to pictures folder from user domain) as alias
set strPicturesPath to POSIX path of aliasPicturesPath as text

set ocidPosixPath to refNSString's stringWithString:strPicturesPath
set ocidFullPathURL to refMe's NSURL's fileURLWithPath:ocidPosixPath
###パッケージなのでこの方法
set ocidPhotosLibraryPathURL to ocidFullPathURL's URLByAppendingPathComponent:"Photos Library.photoslibrary"
###オリジナルのパス
set ocidOriginalsPathURL to ocidPhotosLibraryPathURL's URLByAppendingPathComponent:"originals"
log ocidOriginalsPathURL as text


tell application "Photos"
log name as text
log version as text
log frontmost as boolean
log slideshow running as boolean


#####アルバム関連
set listAlbum to every album as list
log listAlbum
repeat with objAlbum in listAlbum
tell objAlbum
properties
log id of objAlbum as text
log name of objAlbum as text
log parent of objAlbum as text
end tell

end repeat
log selection as list
log id of favorites album as text
log id of recently deleted album as text


####container関連
set listCotainer to every container
repeat with objCotainer in listCotainer
tell objCotainer
log id as text
log name as text
log parent as text
end tell
end repeat


####選択中のメディア
set listSelected to selection as list
###メディアアイテム関連
repeat with objSelected in listSelected
tell objSelected
properties
####ID
set strMediaItemID to id as text as text
set AppleScript's text item delimiters to "/"
set listMediaItemID to every text item of strMediaItemID
set AppleScript's text item delimiters to ""
####ID部分のみ取得
set strMediaID to item 1 of listMediaItemID as text
####IDの最初の1文字
set strMediaIDKey to first character of strMediaID as text
###元のファイル名
set strFileName to filename as text
set AppleScript's text item delimiters to "."
set listFileName to every text item of strFileName
set AppleScript's text item delimiters to ""
###拡張子
set strExtensionName to last item of listFileName as text
log strExtensionName
end tell
if strExtensionName contains "HEIC" then
set strOriginalsDirSaveFileName to strMediaID & ".heic"
else if strExtensionName contains "JPG" then
set strOriginalsDirSaveFileName to strMediaID & ".jpeg"
else if strExtensionName contains "PNG" then
set strOriginalsDirSaveFileName to strMediaID & ".png"
end if
####保存されているディレクトリ(フォルダ)
set ocidOriginalFileSaveDirPath to (ocidOriginalsPathURL's URLByAppendingPathComponent:strMediaIDKey)
####ファイル名を付けると写真データのオリジナルファイル
set ocidOriginalFilePath to (ocidOriginalFileSaveDirPath's URLByAppendingPathComponent:strOriginalsDirSaveFileName)
set strOriginalFilePath to ocidOriginalFilePath's |path| as text
log strOriginalFilePath
log className() of ocidOriginalFilePath as text
end repeat

end tell

####Finderでファイルを選択した状態にする
set boolSelectFileResults to refMe's NSWorkspace's sharedWorkspace()'s selectFile:strOriginalFilePath inFileViewerRootedAtPath:"/"

|

[写真.app]選択中メディアの書き出し (export)

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#error number -128
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions



property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSMutableString : a reference to refMe's NSMutableString
property refNSURL : a reference to refMe's NSURL
property refNSNotFound : a reference to 9.22337203685477E+18 + 5807

set objFileManager to refMe's NSFileManager's defaultManager()

###保存先関連
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
set strDefaultName to "フォルダの名前" as text
set strPromptText to "名前を決めてください"

set aliasSaveDirPath to (choose folder "フォルダを選んでください" with prompt "フォルダを選択してください" default location aliasDefaultLocation without invisibles, showing package contents and multiple selections allowed) as alias


###パス関連
set aliasPicturesPath to (path to pictures folder from user domain) as alias
set strPicturesPath to POSIX path of aliasPicturesPath as text

set ocidPosixPath to refNSString's stringWithString:strPicturesPath
set ocidFullPathURL to refMe's NSURL's fileURLWithPath:ocidPosixPath
###パッケージなのでこの方法
set ocidPhotosLibraryPathURL to ocidFullPathURL's URLByAppendingPathComponent:"Photos Library.photoslibrary"
###オリジナルのパス
set ocidOriginalsPathURL to ocidPhotosLibraryPathURL's URLByAppendingPathComponent:"originals"
log ocidOriginalsPathURL as text


tell application "Photos"
log name as text
log version as text
log frontmost as boolean
log slideshow running as boolean


#####アルバム関連
set listAlbum to every album as list
log listAlbum
repeat with objAlbum in listAlbum
tell objAlbum
properties
log id of objAlbum as text
log name of objAlbum as text
log parent of objAlbum as text
end tell

end repeat
log selection as list
log id of favorites album as text
log id of recently deleted album as text
####選択中のメディア
set listSelected to selection as list
####書き出し
export listSelected to aliasSaveDirPath with using originals
end tell

|

[写真.app]保存されているオリジナルデータのパスを求める

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#error number -128
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL



###パス関連
set aliasPicturesPath to (path to pictures folder from user domain) as alias
set strPicturesPath to POSIX path of aliasPicturesPath as text

set ocidPosixPath to refNSString's stringWithString:strPicturesPath
set ocidFullPathURL to refMe's NSURL's fileURLWithPath:ocidPosixPath
###パッケージなのでこの方法
set ocidPhotosLibraryPathURL to ocidFullPathURL's URLByAppendingPathComponent:"Photos Library.photoslibrary"
###オリジナルのパス
set ocidOriginalsPathURL to ocidPhotosLibraryPathURL's URLByAppendingPathComponent:"originals"
log ocidOriginalsPathURL as text


tell application "Photos"
log name as text
log version as text
log frontmost as boolean
log slideshow running as boolean


#####アルバム関連
set listAlbum to every album as list
log listAlbum
repeat with objAlbum in listAlbum
tell objAlbum
properties
log id of objAlbum as text
log name of objAlbum as text
log parent of objAlbum as text
end tell

end repeat
log selection as list
log id of favorites album as text
log id of recently deleted album as text


####container関連
set listCotainer to every container
repeat with objCotainer in listCotainer
tell objCotainer
log id as text
log name as text
log parent as text
end tell
end repeat


####選択中のメディア
set listSelected to selection as list
###メディアアイテム関連
repeat with objSelected in listSelected
tell objSelected
properties
set strMediaItemID to id as text as text
set AppleScript's text item delimiters to "/"
set listMediaItemID to every text item of strMediaItemID
set AppleScript's text item delimiters to ""
set strMediaID to item 1 of listMediaItemID as text
set strMediaIDKey to first character of strMediaID as text
set strFileName to filename as text
set AppleScript's text item delimiters to "."
set listFileName to every text item of strFileName
set AppleScript's text item delimiters to ""
set strExtensionName to last item of listFileName as text
log strExtensionName
end tell
if strExtensionName contains "HEIC" then
set strOriginalsDirSaveFileName to strMediaID & ".heic"
else if strExtensionName contains "JPG" then
set strOriginalsDirSaveFileName to strMediaID & ".jpeg"
else if strExtensionName contains "PNG" then
set strOriginalsDirSaveFileName to strMediaID & ".png"
end if
####保存されているディレクトリ(フォルダ)
set ocidOriginalFileSaveDirPath to (ocidOriginalsPathURL's URLByAppendingPathComponent:strMediaIDKey)
####ファイル名を付けると写真データのオリジナルファイル
set ocidOriginalFilePath to (ocidOriginalFileSaveDirPath's URLByAppendingPathComponent:strOriginalsDirSaveFileName)
set strOriginalFilePath to ocidOriginalFilePath's |path| as text
log strOriginalFilePath
log className() of ocidOriginalFilePath as text
end repeat

end tell

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom