cupertino-files / ImageModel
Class: ImageModel
Defined in: src/tsd/images.ts:85
Extends
Constructors
Constructor
new ImageModel(
store,object):ImageModel
Defined in: src/tsd/images.ts:86
Parameters
store
object
Returns
ImageModel
Overrides
Properties
object
readonlyobject:IwaObject
Defined in: src/tsd/drawables.ts:92
Inherited from
store
readonlystore:ObjectStore
Defined in: src/tsd/drawables.ts:91
Inherited from
Accessors
accessibilityDescription
Get Signature
get accessibilityDescription():
string|undefined
Defined in: src/tsd/drawables.ts:204
Returns
string | undefined
Set Signature
set accessibilityDescription(
value):void
Defined in: src/tsd/drawables.ts:208
Parameters
value
string | undefined
Returns
void
Inherited from
DrawableModel.accessibilityDescription
dataId
Get Signature
get dataId():
bigint|undefined
Defined in: src/tsd/images.ts:94
Data-space identifier of the primary backing media, if any.
Returns
bigint | undefined
fileName
Get Signature
get fileName():
string|undefined
Defined in: src/tsd/images.ts:126
File name of the primary backing media within Data/.
Note this is TSP.DataInfo.file_name when set (the real on-disk name, which the apps disambiguate by appending the data identifier), falling back to preferred_file_name.
Returns
string | undefined
hasFilters
Get Signature
get hasFilters():
boolean
Defined in: src/tsd/images.ts:305
True when any image filter is applied.
Returns
boolean
hasMask
Get Signature
get hasMask():
boolean
Defined in: src/tsd/images.ts:179
True when the image is clipped by a mask (shape crop / instant alpha).
Returns
boolean
hyperlinkUrl
Get Signature
get hyperlinkUrl():
string|undefined
Defined in: src/tsd/drawables.ts:200
Returns
string | undefined
Inherited from
id
Get Signature
get id():
bigint
Defined in: src/tsd/drawables.ts:99
Returns
bigint
Inherited from
isMaterialized
Get Signature
get isMaterialized():
boolean
Defined in: src/tsd/images.ts:137
True when the primary media is actually present in the package. Apple documents can reference media that was never materialized (optimized storage, template assets); those images render in the app but have no bytes to extract here.
Returns
boolean
originalSize
Get Signature
get originalSize(): {
height:number;width:number; } |undefined
Defined in: src/tsd/images.ts:171
Intrinsic pixel size recorded by the app, if present.
Returns
{ height: number; width: number; } | undefined
type
Get Signature
get type():
number
Defined in: src/tsd/drawables.ts:103
Returns
number
Inherited from
typeName
Get Signature
get typeName():
string|undefined
Defined in: src/tsd/drawables.ts:107
Returns
string | undefined
Inherited from
Methods
clearFilters()
clearFilters():
void
Defined in: src/tsd/images.ts:348
Remove all image filters, restoring the unadjusted rendering.
Returns
void
crop()
crop():
ImageCrop|undefined
Defined in: src/tsd/images.ts:197
The crop, in both the spaces that matter.
window is the visible rectangle in the image's own coordinates — which part of the picture shows. visible is where that lands in the image's parent, which is image.position + mask.position (see docs/FORMAT.md §8.2). An uncropped image has no crop at all.
Returns
ImageCrop | undefined
data()
data():
Uint8Array<ArrayBufferLike> |undefined
Defined in: src/tsd/images.ts:154
Raw bytes of the backing media. Falls back to any other materialized variant (original/adjusted/enhanced/thumbnail) when the primary is not present in the package; dataSource() reports which one was used.
Returns
Uint8Array<ArrayBufferLike> | undefined
dataSource()
dataSource(): {
dataId:bigint;fileName:string|undefined;role:string; } |undefined
Defined in: src/tsd/images.ts:163
Which media variant data would return, if any.
Returns
{ dataId: bigint; fileName: string | undefined; role: string; } | undefined
dataVariants()
dataVariants():
object[]
Defined in: src/tsd/images.ts:103
Every media variant this image references, in preference order: the primary image, then the original, adjusted, enhanced and thumbnail variants the apps keep alongside it.
Returns
object[]
filters()
filters():
ImageFilters
Defined in: src/tsd/images.ts:310
Current image-filter settings ({} when none are applied).
Returns
geometry()
geometry():
GeometryInfo|undefined
Defined in: src/tsd/drawables.ts:115
Returns
GeometryInfo | undefined
Inherited from
mask()
mask():
MaskModel|undefined
Defined in: src/tsd/images.ts:184
The mask drawable defining the crop, if the image has one.
Returns
MaskModel | undefined
removeCrop()
removeCrop():
boolean
Defined in: src/tsd/images.ts:294
Show the whole picture again.
The mask object is left in the package — something else may reference it, and this library never collects the graph — but the image no longer points at it, so the full extent shows at the image's own frame. That frame is larger than the crop was, which is the point.
Returns
boolean
setCrop()
setCrop(
window):void
Defined in: src/tsd/images.ts:237
Choose which part of the picture shows, in image-local points — the image's drawn geometry space, not source pixels: an image scaled to 260 pt wide crops with windows inside 260, wherever the source's pixel count landed. A window outside the drawn frame is one the app renders as a broken top-left crop and refuses to open the mask editor on.
The visible rectangle moves with the window: cropping to {x: 10, …} shifts what appears on the page 10pt right, because the window is positioned relative to the image. To keep the result where it was, call setVisibleFrame afterwards — or use it instead, which does both.
An image with no mask gets one, built as the rectangle Apple writes.
Parameters
window
Returns
void
setFilters()
setFilters(
filters):void
Defined in: src/tsd/images.ts:328
Apply image filters. Only the properties given are changed; pass undefined for a property to clear it. The apps re-render from the untouched original media, so this is non-destructive.
Parameters
filters
Returns
void
setGeometry()
setGeometry(
update):void
Defined in: src/tsd/drawables.ts:132
Move and/or resize. Only the provided components are changed.
Parameters
update
angle?
number
height?
number
width?
number
x?
number
y?
number
Returns
void
Inherited from
setPathRectangle()
setPathRectangle(
width,height):void
Defined in: src/tsd/drawables.ts:180
Rewrite a shape's rectangular path to a new size.
A shape's path renders scaled from the path source's naturalSize to the geometry frame, text and all: 93 of the corpus's 103 text-bearing Keynote boxes store a natural size that differs from their frame, and a text box resized by frame alone shrinks or clips its text against the donor's path — the measured field failure. Pages' own text boxes keep path and frame equal (97 of 97), so a text box resized through this library gets both: setGeometry for the frame, this for the text's coordinate space. Which of the two states Keynote's own resize writes is unmeasured, so the two calls stay explicit rather than one implying the other.
Throws when the shape has no bezier path source, or its path is not a plain axis-aligned rectangle — rewriting a star or an arrow into a box would flatten the shape.
Parameters
width
number
height
number
Returns
void
Inherited from
DrawableModel.setPathRectangle
setVisibleFrame()
setVisibleFrame(
frame):void
Defined in: src/tsd/images.ts:276
Place the cropped result at a rectangle in the parent's space.
Keeps the same part of the picture visible: the image slides so that image.position + mask.position lands on frame, and the window is resized in place. This is the operation "move and resize the cropped image", as opposed to setCrop's "choose what shows".
Parameters
frame
Returns
void
style()
style():
DrawableStyleHandle|undefined
Defined in: src/tsd/drawables.ts:222
Visual style — fill, stroke, opacity, shadow, reflection.
This is where drawable shadows live. Cell and table styles have no shadow field at all, so a shadow on a table means a shadow on the shape or image, not on its cells.
Returns
DrawableStyleHandle | undefined