Login About Gallery
Split Image Equally
Accepts
Images
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
SCRIPTING
If
Input
Condition
SCRIPTING
Show alert
Error
Title
Error
Show Cancel Button
SCRIPTING
Exit shortcut with
Result
End If
VARIABLES
SCRIPTING
If
Input
Condition
PHOTOS
Select photos
Select Multiple
VARIABLES
Set variable
inpImage
to
Input
End If
COMMENT
Setting up the dimensions
VARIABLES
Get
inpImage
MEDIA
Get
Height
from
Image
VARIABLES
Set variable
inpHeight
to
Input
VARIABLES
Get
inpImage
MEDIA
Get
Width
from
Image
VARIABLES
Set variable
inpWidth
to
Input
COMMENT
Determining the number of segments and output dimensions
SCRIPTING
Ask
How many horizontal segments?
Input Type
Number
Default Answer
0
VARIABLES
Set variable
#HorizontalSegs
to
Input
VARIABLES
Get
inpWidth
MATHS
Number
÷
#HorizontalSegs
Options Under Construction
COMMENT
Round down, as rounding errors seem to add 1 row of white pixels (canvas > image)
MATHS
Round
Input
to
Ones Place
Mode
Always Round Down
VARIABLES
Set variable
outWidth
to
Input
SCRIPTING
Ask
How many vertical segments?
Input Type
Number
Default Answer
0
VARIABLES
Set variable
#VerticalSegs
to
Input
VARIABLES
Get
inpHeight
MATHS
Number
÷
#VerticalSegs
Options Under Construction
MATHS
Round
Input
to
Ones Place
Mode
Always Round Down
VARIABLES
Set variable
outHeight
to
Input
COMMENT
Cropping the input image into the sub-images
TEXT
0
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
VARIABLES
Get
inpImage
MEDIA
Crop
Image
Position
Custom
X Coordinate
0
Y Coordinate
y_coord
Width
inpWidth
Height
outHeight
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
VARIABLES
Get
verticalSeg
MEDIA
Crop
Image
Position
Custom
X Coordinate
x_coord
Y Coordinate
0
Width
outWidth
Height
outHeight
PHOTOS
Save
Input
to
Recents
COMMENT
Incrementing our x_coord
VARIABLES
Get
x_coord
MATHS
Number
+
outWidth
Options Under Construction
VARIABLES
Set variable
x_coord
to
Input
End Repeat
TEXT
0
VARIABLES
Set variable
x_coord
to
Input
Otherwise
COMMENT
If we're not splitting it horizontally, we go straight to saving it
VARIABLES
Get
verticalSeg
PHOTOS
Save
Input
to
Recents
End If
COMMENT
Incrementing the y coordination for our loop
VARIABLES
Get
y_coord
MATHS
Number
+
outHeight
Options Under Construction
VARIABLES
Set variable
y_coord
to
Input
End Repeat
SCRIPTING
Show alert
Completed
Title
Completed
Show Cancel Button
SCRIPTING
Exit shortcut with
Result

Showcuts

Magic Vars

Screenshot

Submitted Anonymously 8 days ago

This is an old shortcut, so some variables might be missing!

Visit iCloud (iOS)

Copy iCloud Link

Scan QR Code

0