Skip to content

China-chan/Komiflo-Unscrambler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Komiflo Image Unscrambler

Table of Contents


About

komiflo_unscrambler.py is a small Python script for restoring Komiflo scrambled page images using:

  • user.json
  • content_response.json
  • the scrambled page image itself

The implementation is pure Python and only depends on Pillow for image processing.


Comparison

Scrambled Unscrambled
scrambled_page0 unscrambled_page0

Requirements

  • Python 3.10 or later
  • See requirements.txt for Python dependencies

Input Files

This script expects the following files:

user.json

Get this from:

https://api.komiflo.com/session/user

content_response.json

Get this from:

https://api.komiflo.com/content/id/<target_content_id>

Scrambled image

This is the scrambled page image that corresponds to the page you want to restore.

If you do not specify --image, the script will try to infer the local filename from content_response.json. For example, if imgs[0].filename is https://.../abcdef.jpg?..., the script will look for:

abcdef.jpg

in the output directory or script directory.


Usage

1. Install Dependencies

pip install -r requirements.txt

2. Prepare JSON and Image Files

Place these files in the same directory as komiflo_unscrambler.py, or pass their paths explicitly:

  • user.json
  • content_response.json
  • scrambled image file such as abcdef.jpg

Default file names:

user.json
content_response.json

3. List Available Pages

Before restoring an image, you can inspect the available page indices:

python komiflo_unscrambler.py --list-pages

If your JSON files are stored elsewhere:

python komiflo_unscrambler.py --user-json path/to/user.json --content-json path/to/content_response.json --list-pages

4. Unscramble a Page

Basic example:

python komiflo_unscrambler.py --page 0 --image scrambled_page0.jpg

Specify an output file:

python komiflo_unscrambler.py --page 0 --image scrambled_page0.jpg --output output/unscrambled_page0.jpg

Specify JPEG quality:

python komiflo_unscrambler.py --page 0 --image scrambled_page0.jpg --quality 100 --output output/unscrambled_page0.jpg

Use custom JSON paths:

python komiflo_unscrambler.py --user-json data/user.json --content-json data/content_response.json --page 1 --image images/page1.jpg --output output/page1_restored.jpg

If the image filename already matches the filename in content_response.json, --image can be omitted:

python komiflo_unscrambler.py --page 0 --output-dir output

In that case, the script searches for the input image using the filename stored in content_response.json, rooted at --output-dir.


5. Use as a Python Module

import json

from komiflo_unscrambler import decrypt

with open("user.json", "r", encoding="utf-8") as f:
    user = json.load(f)

with open("content_response.json", "r", encoding="utf-8") as f:
    content = json.load(f)

result = decrypt(
    user_dict=user,
    content_dict=content,
    page="0",
    image_path="scrambled_page0.jpg",
    output_path="output/unscrambled_page0.jpg",
    quality=100,
)

print(result["output_path"])

Notes

  • page is handled as the page index found in the decrypted page map and usually corresponds to content_response.json inside imgs.
  • quality is the JPEG save quality. The default is 95.
  • --list-pages is useful when you want to confirm page numbers, width, height, and seed before running the actual restore.
  • The script does not download images by itself. Prepare the scrambled image file beforehand.

Issues

If the script fails, first check:

  • user.json really comes from https://api.komiflo.com/session/user
  • content_response.json really comes from https://api.komiflo.com/content/id/<target_content_id>
  • the scrambled image matches the selected page
  • the local image filename matches the filename recorded in content_response.json when --image is omitted

Contributors

Languages