diff --git a/INSTALL.md b/INSTALL.md
index 1dfc44c..cf1584a 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -4,11 +4,11 @@ For local development / building stand-alone binaries.
You need [Python 2.7](https://www.python.org/downloads/release/python-2718/).
-If you are using Windows download the
-`Windows x86 MSI installer`
-because 32 bit Python is needed to create
-a Windows executable with `py2exe`.
-The performance increase from 64 bit is negligible.
+If you are using Windows
+and want to build a stand-alone binary
+download the `Windows x86 MSI installer`
+because `py2exe` for Python 2 doesn't work with 64 bit.
+Any performance increase from 64 bit is negligible.
Be sure to add `python` to `PATH` during installation.
@@ -45,7 +45,7 @@ To actually build a stand-alone `.exe`, install
A standalone binary can be created in the `dist` folder via
```
-(venv) > python setup.py install
+(venv) > python setup.py
```
You may get an error which can be solved by looking at
diff --git a/README.md b/README.md
index 05029ec..158d854 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,13 @@
-# Mangle #
+
+
+# Mangle
Mangle is a cross-platform image converter and optimizer built for reading Manga on the Amazon Kindle and other E-ink
devices written in Python. With this application you can easily:
@@ -8,19 +17,12 @@ devices written in Python. With this application you can easily:
* Downsample and rotate images for optimal viewing on Kindle, convert to grayscale to save space and improve contrast.
* Automatically generate book meta-data so that your Manga is always properly detected and viewable in-order.
-### Screenshots ###
+[![](img/kindle1-thumb.png)](img/kindle1.png)
+[![](img/kindle2-thumb.png)](img/kindle2.png)
+[![](img/kindle3-thumb.png)](img/kindle3.png)
+[![](img/kindle4-thumb.png)](img/kindle4.png)
-[![Main window](https://foosoft.net/projects/mangle/img/main-thumb.png)](https://foosoft.net/projects/mangle/img/main.png)
-[![Options dialog](https://foosoft.net/projects/mangle/img/options-thumb.png)](https://foosoft.net/projects/mangle/img/options.png)
-
-### On the Kindle... ###
-
-[![](https://foosoft.net/projects/mangle/img/kindle1-thumb.png)](https://foosoft.net/projects/mangle/img/kindle1.png)
-[![](https://foosoft.net/projects/mangle/img/kindle2-thumb.png)](https://foosoft.net/projects/mangle/img/kindle2.png)
-[![](https://foosoft.net/projects/mangle/img/kindle3-thumb.png)](https://foosoft.net/projects/mangle/img/kindle3.png)
-[![](https://foosoft.net/projects/mangle/img/kindle4-thumb.png)](https://foosoft.net/projects/mangle/img/kindle4.png)
-
-## Motivation ##
+## Motivation
Many years ago I received an Amazon Kindle as a gift. I immediately began playing around with it and reading about
certain undocumented features that the Kindle has to offer. After a couple of hours I discovered it to be the perfect
@@ -54,7 +56,7 @@ However... The Kindle's image viewer does have certain shortcomings:
Mangle was born out of my annoyance with these issues. The program name is a portmanteau of "Manga" and "Kindle"; I
thought it was pretty clever at the time.
-## Usage ##
+## Usage
1. Add the desired images and image directories to the current book.
2. Re-order the images as needed (files pre-sorted alphabetically).
@@ -63,20 +65,14 @@ thought it was pretty clever at the time.
5. Export your images, selecting the `pictures` directory you just created.
6. Enjoy your Manga (if it doesn't show up, press Alt + Z while on the home menu).
-## Dependencies ##
+## Dependencies
* [PyQt4](https://riverbankcomputing.com/software/pyqt/download)
* [Python 2.7](http://www.python.org/download/releases/2.7/)
* [Pillow (PIL)](https://pypi.org/project/Pillow/)
* [ReportLab](https://pypi.org/project/reportlab/)
-## Installation ##
+## Installation
-Pre-build binaries are available for the platforms listed below. I don't have the means to make MacOS X releases myself,
-so I am providing the old (and unsupported) package built by Rob White instead. Linux users should run Mangle directly
-from source.
-
-* [mangle\_win.zip](https://foosoft.net/projects/mangle/dl/mangle_win.zip)
-* [mangle\_osx.zip](https://foosoft.net/projects/mangle/dl/mangle_osx.zip) (quite old)
-
-Check [INSTALL.md](INSTALL.md) for build instructions.
+Pre-built binaries are available for download from the project's [releases
+page](https://github.com/FooSoft/mangle/releases).
diff --git a/img/kindle1-thumb.png b/img/kindle1-thumb.png
new file mode 100644
index 0000000..30db0e7
Binary files /dev/null and b/img/kindle1-thumb.png differ
diff --git a/img/kindle1.png b/img/kindle1.png
new file mode 100644
index 0000000..c0539d2
Binary files /dev/null and b/img/kindle1.png differ
diff --git a/img/kindle2-thumb.png b/img/kindle2-thumb.png
new file mode 100644
index 0000000..eb3850f
Binary files /dev/null and b/img/kindle2-thumb.png differ
diff --git a/img/kindle2.png b/img/kindle2.png
new file mode 100644
index 0000000..8a01743
Binary files /dev/null and b/img/kindle2.png differ
diff --git a/img/kindle3-thumb.png b/img/kindle3-thumb.png
new file mode 100644
index 0000000..55c720b
Binary files /dev/null and b/img/kindle3-thumb.png differ
diff --git a/img/kindle3.png b/img/kindle3.png
new file mode 100644
index 0000000..d65559d
Binary files /dev/null and b/img/kindle3.png differ
diff --git a/img/kindle4-thumb.png b/img/kindle4-thumb.png
new file mode 100644
index 0000000..15a3fa5
Binary files /dev/null and b/img/kindle4-thumb.png differ
diff --git a/img/kindle4.png b/img/kindle4.png
new file mode 100644
index 0000000..3054acd
Binary files /dev/null and b/img/kindle4.png differ
diff --git a/mangle-cli.py b/mangle-cli.py
new file mode 100755
index 0000000..9c8e2b1
--- /dev/null
+++ b/mangle-cli.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python2
+"""python mangle-cli.py extracted_cbz_folder/*
+ -d directory_name defaults to ./
+ -t title defaults 'Unknown'
+ -o book.outputFormat defaults to 'CBZ only'
+
+NOTE order of arguments for image files is significant.
+
+Example:
+
+ mkdir my_comic
+ cd my_comic
+ 7z x /full/path/my/comic.cbz
+ cd ..
+ python mangle-cli.py -tmy_comic my_comic/*
+
+"""
+
+import shutil
+import sys
+import os
+import getopt
+
+import mangle.cbz
+import mangle.image
+from mangle.image import ImageFlags
+
+
+class FakeBook:
+ device = 'Kindle 2/3/Touch' # See mangle/image.py KindleData.Profiles
+ outputFormat = 'CBZ only'
+ title = 'Unknown'
+ imageFlags = ImageFlags.Orient | ImageFlags.Resize | ImageFlags.Quantize
+
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], 'd:t:o:')
+except getopt.GetoptError, err:
+ print(str(err))
+ sys.exit(2)
+
+directory = '.'
+
+book = FakeBook()
+book.device = 'Kindle 2/3/Touch'
+#book.device = 'Kindle Paperwhite 1 & 2'
+book.outputFormat = 'CBZ only'
+book.title = 'Unknown'
+
+
+for o,a in opts:
+ if o == '-d':
+ directory = a
+ elif o == '-t':
+ book.title = a
+ elif o == '-o':
+ book.outputFormat = a
+
+
+bookPath = os.path.join(directory, book.title)
+
+archive = mangle.cbz.Archive(bookPath)
+
+if not os.path.isdir(bookPath):
+ os.makedirs(bookPath)
+
+
+for index in range(0, len(args)):
+ target = os.path.join(bookPath, '%05d.png' % index) # FIXME preserve original; format and name?
+
+ print(index, args[index], target) # cheap display progress
+ mangle.image.convertImage(args[index], target, str(book.device), book.imageFlags)
+ archive.addFile(target);
+
+
+if 'Image' not in book.outputFormat:
+ shutil.rmtree(bookPath)
+
+archive.close()
+
diff --git a/mangle/image.py b/mangle/image.py
index fac3f16..a357022 100644
--- a/mangle/image.py
+++ b/mangle/image.py
@@ -157,6 +157,16 @@ def fitImage(image, size, method=Image.ANTIALIAS):
@protect_bad_image
def fillImage(image, size):
+ widthDev, heightDev = size
+ widthImg, heightImg = image.size
+
+ imgRatio = float(widthImg) / float(heightImg)
+ devRatio = float(widthDev) / float(heightDev)
+
+ # don't crop 2 page spreads.
+ if imgRatio > devRatio:
+ return resizeImage(image, size)
+
return ImageOps.fit(image, size, Image.ANTIALIAS)
@@ -202,6 +212,9 @@ def orientImage(image, size):
widthDev, heightDev = size
widthImg, heightImg = image.size
+ if widthImg <= widthDev and heightImg <= heightDev:
+ return image
+
if (widthImg > heightImg) != (widthDev > heightDev):
return image.rotate(90, Image.BICUBIC, True)
return image
diff --git a/requirements.txt b/requirements.txt
index decdd52..7a2c36e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,3 @@
-Pillow==6.2.2
py2exe-py2==0.6.9; platform_system=='Windows'
PyQt4 @ https://download.lfd.uci.edu/pythonlibs/w4tscw6k/cp27/PyQt4-4.11.4-cp27-cp27m-win32.whl; platform_system=='Windows'
reportlab==3.5.59