COMMENT
This shortcut will split an image into equally sized segments.
Created by u/Joe__Soap on reddit.
VARIABLES
Set variable
inpImage
to
Input
SCRIPTING
Count
Items
in
Input

Count
SCRIPTING
If
Input
Condition
SCRIPTING
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
VARIABLES
Get
Count
SCRIPTING
If
Input
Condition
PHOTOS

Photos
VARIABLES
Set variable
inpImage
to
Input
SCRIPTING
End If

If Result
COMMENT
Setting up the dimensions
VARIABLES
Get
inpImage
MEDIA
Get
Height
from
Image

Height
VARIABLES
Set variable
inpHeight
to
Input
VARIABLES
Get
inpImage
MEDIA
Get
Width
from
Image

Width
VARIABLES
Set variable
inpWidth
to
Input
COMMENT
Determining the number of segments and output dimensions
SCRIPTING
Ask
How many horizontal segments?

Provided Input
VARIABLES
Set variable
#HorizontalSegs
to
Input
VARIABLES
Get
inpWidth
MATHS
Number
÷
#HorizontalSegs
Options Under Construction

Calculation Result
COMMENT
Round down, as rounding errors seem to add 1 row of white pixels (canvas > image)
MATHS
Round
Input
to
Ones Place

Rounded Number
VARIABLES
Set variable
outWidth
to
Input
SCRIPTING
Ask
How many vertical segments?

Provided Input
VARIABLES
Set variable
#VerticalSegs
to
Input
VARIABLES
Get
inpHeight
MATHS
Number
÷
#VerticalSegs
Options Under Construction

Calculation Result
MATHS
Round
Input
to
Ones Place

Rounded Number
VARIABLES
Set variable
outHeight
to
Input
COMMENT
Cropping the input image into the sub-images
TEXT
0

Text
VARIABLES
Set variable
x_coord
to
Input
VARIABLES
Set variable
y_coord
to
Input
COMMENT
We'll split into horizontal segments first
SCRIPTING
Repeat
#VerticalSegs

Repeat Results
VARIABLES
Get
inpImage
MEDIA
Crop
Image
Y Coordinate
y_coordWidth
inpWidthHeight
outHeight

Cropped Image
VARIABLES
Set variable
verticalSeg
to
Input
VARIABLES
Get
#HorizontalSegs
SCRIPTING
If
Input
Condition
COMMENT
Image has been split vertically first, now to split horizontal as well
SCRIPTING
Repeat
#HorizontalSegs

Repeat Results
VARIABLES
Get
verticalSeg
MEDIA
Crop
Image
X Coordinate
x_coordWidth
outWidthHeight
outHeight

Cropped Image
PHOTOS
Save
Input
to
Recents

Saved Photo Media
COMMENT
Incrementing our x_coord
VARIABLES
Get
x_coord
MATHS
Number
+
outWidth
Options Under Construction

Calculation Result
VARIABLES
Set variable
x_coord
to
Input
SCRIPTING
End Repeat

Repeat Results
TEXT
0

Text
VARIABLES
Set variable
x_coord
to
Input
SCRIPTING
Otherwise
COMMENT
If we're not splitting it horizontally, we go straight to saving it
VARIABLES
Get
verticalSeg
PHOTOS
Save
Input
to
Recents

Saved Photo Media
SCRIPTING
End If

If Result
COMMENT
Incrementing the y coordination for our loop
VARIABLES
Get
y_coord
MATHS
Number
+
outHeight
Options Under Construction

Calculation Result
VARIABLES
Set variable
y_coord
to
Input
SCRIPTING
End Repeat

Repeat Results
SCRIPTING
SCRIPTING
Exit shortcut with
Result