Skip to content

A hotchpotch of scripts to split a picture. Used in a personal project

License

CC0-1.0, MIT licenses found

Licenses found

CC0-1.0
LICENSE
MIT
LICENSE-split
Notifications You must be signed in to change notification settings

Cosmic-Infinity/split-it-all

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

split-it-all

It was a dark and stormy night. In a room humid with sweat, temperature reached 29°C. The night slipped from 3rd to 4th, it was March of 2022, Friday. I had school the other day, and yet, I was up all night trying to extract images from this japanese VN.

This was a curious case. After somehow extracting the the files from this absurd .arc format, I was at a loss. Each animations, as it seemed, was a long image file with each animation frame placed side to side. Each frame measuring 960 pixels wide. I wanted those animations bad. But manually cutting up each frame perfectly was near about impossible. So, I did what every self proclaimed programmer would. I considered automating it all with code.

The Journey (not worth reading. this is a note to self)

This project is a culmination of a lot of things. Call it stubbornness, or overconfidence, I was sure it was just a matter of an hour. "1 or 2 am at most", I thought, and having compiled a few scripts in Autoit before, I got started.

🔴 Batch files are used for automation. Maybe I can write something up? (I knew 0 thing about batch scripting)

🟠 Batch files support drag n' drop. I need drag n' drop. Ok. No more Autoit then.

🟡 But then how do it split it? Batch files cannot process image. I need something else

🟢 Okay, I found this split-image project on github. How do I use it? Oooookay it's in python (why does it have to be python)

🔵 Fine I can pass some arguments into it's cli via the batch file.

🟣 So I have to mention the number of splits I want, but... batch files can't process image. I need to read the image width, and find the number of splits. And, I can't write python 🥲

🟤 Well, Autoit it is then. I should read the image, find possible splits, and then pass that information to the batch file which will then pass that to split.py

⚫ BUT how do I pass data between autoit and batch file? * an hour of brute force later* FINE text file it is.

⚪ So there I was. Hours in and a project with a million pieces.

How it works

  1. User Drag n' Drops an image to START.bat

Drop file in START.bat


  1. STRAT.bat renames the file to replace space with underscore (space causes issues while handling image in autoit). And passes control over to split.bat.

Pass renamed image to split.bat


  1. split.bat creates a new folder with the same name as the image, and moves the image into that folder.

split.bat moves image to folder


  1. split.bat creates a text file and writes the address of the image to the first line.

split.bat creates text file with address of the image


  1. split.bat starts width.au3 (or .exe).

split.bat starts width.au3


  1. width.au3 reads the text file to get the location of the image. It then calculates the number of horizontal splits it can perform based on the split width hardcoded in the script. It then writes that number in the first line of the text file. Control is then returned to split.bat

calculating possible splits
Vertical splits are NOT performed as it was not required for my use case

width.au3 writes the number of possible splits to the text file


  1. split.bat then takes both, the image and the possible split integer, and passes it to split.py.

split.bat passes all information to split.py


  1. split.py can perform both horizontal and vertical splitting. Bases on requirement, it horizontally splits the image.

Images are split and placed in folder


  1. The results are present in a folder as the same name as the imput image, just with underscores in place of spaces.

Output


Algorithm flow


Screenshot 2023-04-01 183234

  1. Input image drag n' drop.

  2. Renamed file location paased.

  3. Passed new folder location through a text file.

  4. Returned split count through the text file.

  5. Passed image location and split count.

  6. Output files generated.

Run/Compile from source

By default the size of each horizontal split is 960 pixel. There is no vertical splits.

Run : You'll need Autoit runtime and Python installed to use the scripts directly from code. Drag and drop the require image to START.bat to use it. Launching the batch files directly do nothing.

Compile : Autoit provides a direct tool to convert to .exe and you may use pyinstaller to convert the python script to an .exe as well. The batch files need not be modified.

Released Packages

NOTE: I feel like I need to say it every time, but Windows likes to flag almost everything I write as virus. No, I am not a malware author. The code is open for you to inspect. Yes, it is a false positive.

The package present in the release contains all the scripts in a runnable format, i.e. as .exe or .bat.

width.exe has hard coded size of horizontal split set to 960 pixel

and you cannot change that from the execuatble. If you plan to use it for other sizes, I recommend downloading and separately recompiling width.au3 with your own custom width value.

in-action

About

A hotchpotch of scripts to split a picture. Used in a personal project

Topics

Resources

License

CC0-1.0, MIT licenses found

Licenses found

CC0-1.0
LICENSE
MIT
LICENSE-split

Stars

Watchers

Forks

Packages

No packages published