This series talk about Cocoa + AppleScript. From basic & essential knowledges to expert Cocoa script.
#5 is about NSImage.NSImage is basic Cocoa class to handle images.
You can read each NSImage methods reference in AppleScript way.
PDF 473 pages + Zip archive.
■ Chapter 1: Introduction
Overview of Cocoa Scripting
What is Cocoa Scripting?
Practical Use of Cocoa Scripting
Power of Cocoa Scripting
Advantages of Cocoa Scripting
Requirements for Cocoa Scripting
Summary of Cocoa Scripting
Nine Principles of Cocoa Scripting
macOS Suitable for Cocoa Scripting
Evolutionary History of Cocoa Scripting Environment
Cocoa Scriptable macOS
Reference Materials: AppleScript Runtime Environment Information
Differences in Behavior Across Cocoa Scripting Environments
Pros and Cons of System Integrity Protection (SIP)
Programming Style
Differences in Development and Execution Environments
Differences in Processing Procedures
Scripting Functions Requiring Main Thread Execution
Delegation and Notification
Rewriting Due to Differences in Execution Styles
When Calling Cocoa Objects with AppleScript…
Subroutine Descriptions
Using “my” and “me” to Indicate Object Hierarchy
Class Extensions
Writing Efficient Cocoa Scripts
Interaction with Applications
Implicit Type Conversion
Necessary Rewrites for Some Commands
Correcting Parentheses indicating Calculation Precedence
Counting Objects
Finding Information
How to Research Cocoa Scripting
Apple’s Online Documentation
“Quick Open” Header Files in Xcode
Navigating Header Files
Structure Elements of Header Files
Encountering Deprecated Features
Patterns for Enum (Constants) Not Exceeding AppleScript’s Numeric Representation Width
■ Chapter 2: Practical Guide
Running Cocoa Script in Action
Launching Script Editor/Script Debugger
Executing Cocoa Script
Displaying Logs of Cocoa Objects
Saving Cocoa Script Documents
Export Formats for Cocoa Script
Translating Objective-C’s Cocoa Invocation Syntax to AppleScript
Configuration of Cocoa Script (AppleScriptObjC)
Conversion of Various Objective-C Data Representations (1/3)
Conversion of Various Objective-C Data Representations (2/3)
Conversion of Various Objective-C Data Representations (3/3)
Capitalization of Cocoa Method Names
Conversion of Cocoa Method Names (1/3)
Conversion of Cocoa Method Names (2/3)
Conversion of Cocoa Method Names (3/3)
Introduction to Fundamental Cocoa Objects
Parameters When Calling Methods
NSString (String)
NSArray (Array)
NSDictionary (Dictionary)
Number (Numeric)
Enum (Constants)
nil
NSObject
Distinct Behaviors of Cocoa Scripting
Object Conversion between AppleScript and Cocoa
Cocoa Classes Corresponding to AppleScript Objects
Cocoa Classes Related to Arrays
Cocoa Classes Related to Records
Cocoa Classes Related to Strings
Cocoa Classes Related to Dates
File Path-Related Objects
Methods for Converting File Path-Related Objects
Cocoa Objects Related to Images
File Path Strings (NSString) Related (1/2)
File Path Strings (NSString) Related (2/2)
URL Related
Remote URL String Related (1/2)
Remote URL String Related (2/2)
Local File URL String Related
Array Related
Dictionary Related
NSString Character Encoding Related
Color Related
HTML Related
Conversion and Generation of Cocoa Objects
NSData
Styled String (1/2)
Styled String (2/2)
Two-Dimensional Coordinate Data
One-Dimensional Coordinate System Data
Language and Locale Data
Useful Cocoa Objects (Excerpt)
■ Chapter 3: NSImage
Position and Role of NSImage
Understanding Frameworks by Application
NSImage
Applications of NSImage
Notable Considerations for NSImage
NSImage Basic Samples
imageNamed:①
imageWithSystemSymbolName:① accessibilityDescription:②
setName:①
name
initWithContentsOfFile:①
initWithContentsOfURL:①
initWithData:①
initWithSize:①
size
canInitWithPasteboard:①
imageTypes
imageUnfilteredTypes
prefersColorMatch
usesEPSOnResolutionMismatch
matchesOnMultipleResolution
valid
backgroundColor
resizingMode
lockFocus
lockFocusFlipped: (1)
unlockFocus
cacheMode
TIFFRepresentation
■ Chapter 4: Image Processing Basics
Commonly Used AppleScript + NSImage Functions
List of Basic Processes
Commonly Used Basic Processes with AppleScript + NSImage
Reproducibility of Image Colors
Image Types Recognized by NSImage
Accessing Photoshop Data
Loading Image Files
Loading Image Files
Writing Image Files
Writing Image Files
Retrieving Computer Icon Images
Retrieving Computer Icon Images
Filling Images
Filling Rectangular Regions of Images
Filling Circular Regions of Images
Filling Images with Transparent Color (1)
Filling Images with Transparent Color (2)
Creating Colors
Creating Images with Colors Specified by choose color
Filling Images with Rounded Corners
Filling Images with Rounded Corners (1)
Filling Images with Rounded Corners (2)
Converting Image File Formats
Converting Image File Formats
Saving Specified Images as PNG
Saving Specified Images as TIFF
Saving Specified Images as JPEG
Saving Specified Images as BMP
Saving Specified Images as GIF
Saving Specified Images as ICNS
Saving Specified Images as PDF
Resizing Images (Resize)
Resizing Images (Resize)
Resizing Images with Antialiasing
Resizing Images without Antialiasing
Retrieving Image Details
Retrieving Image Details
Retrieving Exif Data from JPEG Files (1)
Retrieving Exif Data from JPEG Files (2)
Reading Metadata Assigned by macOS (1)
Reading Metadata Assigned by macOS (2)
Other Image Information
Cropping Images
Cropping Images
Trimming within a Specified Rectangular Range (1)
Trimming within a Specified Rectangular Range (2)
Automatically Cropping “Margin” Parts
Checking for Corrupted Images
Checking for Corrupted Images
Specifying a Color for Transparent Background Images
Specifying a Color for Transparent Background Images (1)
Specifying a Color for Transparent Background Images (2)
Retrieving Color Information of Specified Coordinates in an Image
Retrieving Color Information of Specified Coordinates in an Image
Replacing Specified Colors in an Image with Any Color
Replacing Colors in an Image (1)
Replacing Colors in an Image (2)
Converting Images to Base64 String
Converting Images to Base64 String
Combining Multiple Images
Combining Multiple Images (Horizontal)
Combining Multiple Images (Horizontal)
Processing Animated GIFs
Processing Animated GIFs
Counting the number of frames in an animated GIF
Decomposing an animated GIF into individual GIF images
Decomposing an animated GIF into PNG images
Drawing text onto an image
Drawing text onto an image (creating a new image) ①
Drawing text onto an image (creating a new image) ②
Drawing text onto an image (drawing onto an existing image) ①
Drawing text onto an image (drawing onto an existing image) ②
Applying filters to an image
Applying filters to an image
Executing CIFilters on an image ①
Executing CIFilters on an image ②
Executing GPUImage filters on an image ①
Executing GPUImage filters on an image ②
■Chapter 5: Advanced Image Processing
Duplicate image detection
Duplicate image detection ①
Duplicate image detection ②
Image text recognition (OCR) processing
Image text recognition (OCR) processing
Image recognition processing
Face recognition processing on an image ①
Face recognition processing on an image ②
Face recognition processing on an image ③
Face recognition processing on an image ④
Shape recognition on an image ①
Shape recognition on an image ②
Shape recognition on an image ③
Shape recognition on an image ④
Image text recognition ①
Image text recognition ②
Image text recognition ③
QR code and barcode image creation/recognition processing
QR code and barcode image creation/recognition
QR code image creation ①
QR code image creation ②
QR code image recognition ①
QR code image recognition ②
QR code image recognition ③
1D barcode image creation ①
1D barcode image creation ②
1D barcode image creation using CIFilter ①
1D barcode image creation using CIFilter ②
Image composition processing
Image composition processing ①
Image composition processing ②
Image composition processing ③
Image composition processing ④
Image composition processing ⑤
Image composition processing ⑥
Blank image detection processing
Blank image detection processing ①
Blank image detection processing ②
Blank image detection processing ③
Image sorting using machine learning models
Image sorting using machine learning models
Program to evaluate specified images with mlmodel
Calling a judgment framework with mlmodel-containing script
Image sorting script using mlmodel ①
Image sorting script using mlmodel ②
Super-resolution processing (2x)
Super-resolution processing
Color space conversion
Color space conversion
Converting images to grayscale
■Sample Script Introduction
Collection of sample scripts
Attached frameworks and libraries (1/2)
Attached frameworks and libraries (2/2)
■Reference Section
AppleScript commands related to Cocoa Scripting
Cocoa Scripting and Script Object (Script statements)
Performing Cocoa Scripting within Script Objects
Indirect invocation of handlers
AppleScript droplets
Writing droplets to bypass security restrictions
Calling third-party frameworks and AppleScript libraries
Including frameworks/AppleScript libraries in a script bundle
Evolution of Shane Stanley’s Script Tool
Shane Stanley’s Script Libraries
Piyomaru Software’s Script Libraries
Major frameworks accessible from AppleScript
OS frameworks accessed from AppleScript
Changes in each macOS framework
AppleScript mini reference
AppleScript-related documentation included in macOS
Sources of AppleScript-related information
macOS versions and trends in AppleScript
Historical overview of macOS and AppleScript elements
Explanation of AppleScript for each macOS version
History of AppleScript auxiliary tools within macOS
Changes in the AppleScript terminology dictionary for System Events
AppleScript runtime environment information
Characteristics of the AppleScript runtime in Claris FileMaker Pro
Considerations for Cocoa Scripting in FileMaker Pro
Various runtime environments and related tools for AppleScript
Embedded application menus ①
Embedded application menus ②
Tools related to Cocoa Scripting
List of AppleScript reserved words
Error code table
Comprehension assessment test