Coder Social home page Coder Social logo

cosmic-infinity / split-it-all Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 25.3 MB

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

License: Creative Commons Zero v1.0 Universal

Batchfile 6.29% Python 85.03% AutoIt 8.68%
autoit automation batch-script image-manipulation python

split-it-all's Introduction

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

split-it-all's People

Contributors

whiplashoo avatar cosmic-infinity avatar pauldebus avatar kimtth avatar jungyitsai avatar lyntny4n avatar mcdominik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.