ShareShortcuts
Создать форк «Split Image»

Создали что-то новое на основе этой команды? Поделитесь ей как форком: она станет вашей собственной командой, которой вы управляете, а обе страницы будут ссылаться друг на друга, чтобы cdmoro получил(а) признание.

  1. 1Получите команду и измените её в приложении «Быстрые команды». Дайте ей собственное название.
  2. 2Поделись ею из приложения «Быстрые команды» и скопируй ссылку iCloud.
  3. 3Вернись сюда, вставь ссылку и опиши, что изменилось, например: «Добавлен шаг, который использует Apple Intelligence для персонализации текста».
Загрузки
28K
Сохранено
2
Действия
38
Категория
Photos and videos
Версия
1.1
Язык
EN

Просмотр

A dead simple image splitter with some fancy features:

  • Pick one or multiple images for bulk jobs
  • Shows a warning when the number of tiles is too big
  • It comes with presets to save time but you can add your own (look into the file settings.json in Shortcuts/SplitImage folder)

Tip: For a smooth user experience, use it in quick actions.

INSTRUCTIONS

There are two ways to split images:

  • One value, if you enter only one value, for instance, "2", will split your image into a grid of 2x2.
  • Two values, set two numbers separated by "." to customise the horizontal and vertical segments, for example, "1.2" will cut your image vertically generating two images. The possibilities are endless (try to avoid high values, which will produce massive images).

Hope you like it!

UPDATE

The new version uses the decimal separator to set the horizontal and vertical segments. If you have installed the first version, please install the shortcut again and delete the settings.json file first and run the shortcut to generate a new settings file. Although, It will work with the old separator (and with any non-number separator).

Что нового

Версия 1.1

Icons in the menu, custom segments dialog now accept only numbers (using decimal character as divider)

История версий
1.1 31 дек 2023 г.

Icons in the menu, custom segments dialog now accept only numbers (using decimal character as divider)

1.0 29 дек 2023 г.

First release

Что делает

Действий: 38
  1. Count
  2. Text
  3. Get File
  4. If
  5. Dictionary
  6. Save File
  7. Add to Variable
  8. Text
  9. Add to Variable
  10. Text
  11. Add to Variable
  12. Choose from List
  13. If
  14. Stop This Shortcut
  15. If
  16. Ask for Input
    …
  17. If
  18. Get Variable
  19. Replace Text
  20. Split Text
  21. Get Item from List
  22. Get Item from List
  23. Calculate Expression
  24. If
  25. Calculate
  26. Text
  27. Show Alert
  28. Repeat with Each
  29. Get Details of Images
  30. Get Details of Images
  31. Calculate
  32. Calculate
  33. Repeat
  34. Calculate Expression
  35. Repeat
  36. Calculate Expression
  37. Crop Image
  38. Create Album

Посмотреть как код
Бета

Все действия этой команды, записанные на Cherri — языке программирования для приложения «Быстрые команды». Отлично подходит, чтобы разобраться, как она работает.

#include 'actions/text'
#include 'actions/documents'
#define color teal
#define glyph crop

const Images = count(ShortcutInput)
const Message = "Images selected: {Images}\n\nInstructions\n- One number to get a symmetrical grid.\n- Two numbers (use decimal separator) to set horizontal and vertical segments individually.\n\nHow many segments?"
const SettingsFile = getFileFromFolder(, "SplitImage/settings.json", false)

const presets = if !SettingsFile {
	const Dictionary = {
		"presets": [
			"1.2",
			"2",
			"2.1",
			"3"
		]
	}
	saveFile("SplitImage/settings.json", Dictionary)
}
@Options = presets['presets']
@Options += "#️⃣ Custom"
@Options += "⏏️ Quit"
const ChosenItem = chooseFromList(@Options, Message, false)

if ChosenItem == "⏏️ Quit" {
	stop()
}

if ChosenItem == "#️⃣ Custom" {
	prompt(Message, "Number", false)
} else {
	// TODO: Get Variable not supported: Assign variable here to 'ChosenItem'.
}
const UpdatedText = replaceText("\D", " ", Segments, false, true)
const SplitText = splitText(UpdatedText, ":")
const TilesX = getRandomItem(SplitText)
const TilesY = getListItem(SplitText, 0)
const ImagesToGenerate = Images * TilesX * TilesY

if ImagesToGenerate > 9 {
	const NumberOfTilesPerImage = TilesX * TilesY
	confirm()
}

for _ in ShortcutInput {
	const Width = getImageDetail(@RepeatItem, "Width")
	const Height = getImageDetail(@RepeatItem, "Height")
	const TileWidth = Width / TilesX
	const TileHeight = Height / TilesY
	repeat _ for TilesX {
		const XCoord = TileWidth * (@RepeatIndex2 - 1)
		repeat _ for TilesY {
			const YCoord = TileHeight * (@RepeatIndex3 - 1)
			const CroppedImage = cropImage(@RepeatItem, TileWidth, TileHeight, "Custom", XCoord, YCoord)
			createAlbum("Split Image", CroppedImage)
		}
	}
}
Открыть в Cherri Playground Декомпилировано с помощью cherri 2.3.0 (GPL-2.0). Перед компиляцией могут понадобиться небольшие исправления.

Оценки и отзывы

Написать отзыв
–
из 5
★★★★★
★★★★
★★★
★★
★
0 ratings

Пока нет отзывов. Поделись мнением первым!

Реклама

Ещё от cdmoro

См. все

Вам также может понравиться

См. все
Реклама