The following is a guide to batch generating single frame images (as single files) from scanned Manga pages.
Motivation: Yesterday evening, while reading Bakuman on my kindle I became painfully conscious of how small the damned screen was. I thought to myself "wouldn't it be nice, if each and every frame were blown up on one page of my kindle? One could actually appreciate the artwork then..." So I bravely set out on this quest, into the world wide web (port Google).
You will need:
BIMP batch image plugin (gimp2),
Divide Scanned Images Plugin (gimp2),
Step 1: Renaming Scans
1.a:The scans must be renamed, such that the two gimp plugins and the autoit scripts can parse the files in the correct order. Assuming your scans are in a folder, already in order, select all files in the folder by left-clicking any file once and pressing CTRL+A. Once all of your scanned files are selected, right-click the FIRST file in the list and in the drop down menu select rename. Name the file "B" (without quotes, just the letter B). This should rename all files in the folder to:
1.b: Install Autoit3. Now we must rename our renamed scan files yet again using an Autoit script. Save the following script into the same folder as the scans as "scanRename.au3"
Note: You can have at most 9999 Scanned files in the folder for this script to work.
$imgcount = 9999; change this to how many files are in the folder
@workingDir & "\B1 (" & $k & ").jepg")
If ($k < 10) Then
FileMove(@workingDir & "\A (" & $k & ").jpg",@workingDir & "\IMAGE_000" & $k & ".jpg")
ElseIf ($k < 100) Then
FileMove(@workingDir & "\A (" & $k & ").jpg",@workingDir & "\IMAGE_00" & $k & ".jpg")
ElseIf ($k < 1000) Then
FileMove(@workingDir & "\A (" & $k & ").jpg",@workingDir & "\IMAGE_0" & $k & ".jpg")
FileMove(@workingDir & "\A (" & $k & ").jpg",@workingDir & "\IMAGE_" & $k & ".jpg")
Until $k = $imgcount+1
The Autoit script "scanRename.au3" will rename all files to:
Check random images in the scan Folder if they are indeed in the correct order.
Step 2: Batch Mirroring all images:
Note: I will explain why we are mirroring all images in step 3. For this we will need to have Gimp 2 installed and also the Plugin BIMP. To install BIMP, follow the instructions on the plugin's website.
2.a: To batch mirror the correctly named scans, we open up Gimp2. In the main menu of the Gimp2 interface we select File -> Batch Image Manipulation.... This will open up a window called "Batch Image Manipulation Plugin". Select "Add" in the upper left corner of this newly opened window. Then, in the Drop down menu, select "Flip or Rotate". This should open yet another smaller window "Flip or Rotate", select "Horizontally" (the left button) and press the "OK" button.
Now we add our Scans Folder: Select "Add images", again in the "Batch Image Manipulation Plugin" window, and in the drop down menu select "add folders..." and select the folder with your scans. You should see a list of the scan files, with their full paths in the "Batch Image Manipulation Plugin" window. Now we must specify where the new mirrored images will be saved. First create a folder called "Mirrored Scans". Click the button (should be labeled as your computers username) next to "Output folder". Select the folder "Mirrored Scans" or any other folder. Now press "Apply". This brings up another window with a process bar, and can take a few minutes to compute. After the process is complete, press "Close".
Step 3: Generating single-frame Files from mirrored Scans
For this step you must install the second plugin for gimp: Divide Scanned Images Plugin (gimp2). Follow the instructions on the website.
Open Gimp2. Select "Filters -> Batch tools -> Batch divide Scanned images". In the drop down menu labeled "Load from:" select the folder "Mirrored Scans"
Set the following values to:
Selection Threshold to 25.0
Size Threshold 145.0
Abort Limit 15.7
Now , in thedrop down menu labeled "Save Directory:" select a folder to which all the single frames should be saved, for example "Single Image Output".
3.b: Repeat Step 2 on the "Single Image Output" Scan folder. This way all single mirrored images are flipped back to normal. Note: the reason we do all this mirroring is to "trick" the Divide Scanned Images Plugin, since it parses images from Left to right, top to bottom. By flipping the images, we get the images in the right sequence, but unreadable, because the text is mirrored, but mirroring all these single frames takes care of that.
Step 4: Corrections [Optional]
As it happens, the "Batch divide Scanned Images" plugin is not perfect, and occasionally makes mistakes. The parser can get the order wrong, or skip a frame (maybe 1 in 400). You can play around with the Selection Threshold, Size Threshold and Abort Limit since this definitely plays a role, (I still am not entirely sure what the three parameters are doing, and they still could use some fine tuning). This is why I wrote a second Autoit script, which allows us to move images around in the folder. For example:
There are ten images named IMAGE_0001, IMAGE_0002. IMAGE_0003, ... IMAGE_0010. And lets say that IMAGE_0006 is 4 frames too late, and should actually be IMAGE_0002. If we would manually rename all files correctly then we would have to rename a total of 6 times to iron out this mistake.
the Autoit script takes care of this. Read the Manga from front to back, note down the images that are in the wrong place, and which image number they should actually be.
Now create a file called "MangaShifterList.csv"
Global Const $CSVFILE = @WorkingDir & "\MangaShifterList.csv"
Global Const $DELIM = ";" ;the delimiter in the CSV file
Global $fileCount = 0;
Local $vecArt ; array to which the list of artists is copied.
If _FileReadToArray($dir_csv, $rawFile, 1) Then
$vecArt = StringSplit($rawFile, $DELIM)
$fileCount = $vecArt*0.5
For $w = 1 To $fileCount Step +1
MsgBox(48, "", "Error opening file!No File in: " & $dir_csv)
If Mod(UBound($vecArt), 2) = 0 Then
MsgBox(48, "", "Error, uneven number of files specified")
If ($numb < 10) Then
ElseIf ($numb < 100) Then
ElseIf ($numb < 1000) Then
MsgBox(0, "Error", "Decimal_Place fucked up")
FileMove(@WorkingDir & Decimal_Place($pageNumb) & $pageNumb & ".jpg", @WorkingDir & Decimal_Place($pageNumb) & $pageNumb & "t.jpg")
Func Rename($pageNumb, $shiftNumb)
FileMove(@WorkingDir & Decimal_Place($pageNumb) & $pageNumb & "t.jpg", @WorkingDir & Decimal_Place($shiftNumb) & $shiftNumb & ".jpg")
Func Shift($pageNumb, $shiftNumb)
$delta = $shiftNumb - $pageNumb
If ($delta < 0 ) Then
$delta = Abs($delta)
For $k = 0 To $delta Step +1
For $k = 1 To $delta Step +1
ElseIf ($delta > 0 ) Then
For $k = 0 To $delta Step +1
For $k = 1 To $delta Step +1
in this file you write for example:
this means: file 4 must be file 3, file 104 must be 100, file 309 must be 305.
Save the csv file and execute the Autoit3 script in the same folder as the scanned images. The Script will resort All of the images in the desired sequence.
This took way too long to write. I hope someone uses this. jesus...