Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packagification and Tests #11

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
build
src/*.egg-info
14 changes: 14 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=======
CHANGES
=======

1.0.0 (unreleased)
------------------

- Initial PyPI release.

- Modified code to create proper package.

- Added tests.

- Added console script entry point.
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include README.md
include test_comp.sh
recursive-include src *.jpg
recursive-include src *.pdf
recursive-include src *.png
recursive-include src *.py
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ img2pdf
Lossless conversion of images to PDF without unnecessarily re-encoding JPEG and
JPEG2000 files. Thus, no loss of quality and no unnecessary large output file.

background
Background
----------

PDF is able to embed JPEG and JPEG2000 images as they are without re-encoding
Expand All @@ -15,7 +15,7 @@ If you know how to embed JPEG and JPEG2000 images into a PDF container without
recompression, using existing tools, please contact me so that I can put this
code into the garbage bin :D

functionality
Functionality
-------------

The program will take image filenames from commandline arguments and output a
Expand Down Expand Up @@ -46,7 +46,7 @@ imagemagick. While a run of above convert command with a 2.8MB JPEG takes 27
seconds (on average) on my machine, conversion using img2pdf takes just a
fraction of a second.

commandline arguments
Commandline Arguments
---------------------

At least one input file argument must be given as img2pdf needs to seek in the
Expand All @@ -67,7 +67,7 @@ Specify -C or --colorspace to force a colorspace using PIL short handles like

More help is available with the -h or --help option.

bugs
Bugs
----

If you find a JPEG or JPEG2000 file that, when embedded can not be read by the
Expand All @@ -86,3 +86,31 @@ I have not yet figured out how to read the colorspace from jpeg2000 files.
Therefor jpeg2000 files use DeviceRGB per default. If your jpeg2000 files are
of any other colorspace you must force it using the --colorspace option.
Like -C L for DeviceGray.

Installation
------------

You can install the package using:

$ pip install img2pdf

If you want to install from source code simply use:

$ cd img2pdf/
$ pip install .

To test the console script without installing the package on your system,
simply use virtualenv:

$ cd img2pdf/
$ virtualenv ve
$ ve/bin/pip install .

You can then test the converter using:

$ ve/bin/img2pdf -o test.pdf src/tests/test.jpg

Note that the package can also be used as a library as follows:

import img2pdf
pdf_bytes = img2pdf('test.jpg', dpi=150)
36 changes: 36 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from setuptools import setup

setup (
name='img2pdf',
version='1.0.0.dev0',
author = "Johannes 'josch' Schauer",
description = "Convert images to PDF via direct JPEG inclusion.",
long_description = open('README.md').read(),
license = "GPL",
keywords = "jpeg pdf converter",
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: Implementation :: CPython',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python',
'Natural Language :: English',
'Operating System :: OS Independent'],
url = 'http://pypi.python.org/pypi/img2pdf',
package_dir={"": "src"},
py_modules=['img2pdf', 'jp2'],
include_package_data = True,
test_suite = 'tests.test_suite',
zip_safe = True,
install_requires=(
'Pillow',
),
entry_points='''
[console_scripts]
img2pdf = img2pdf:main
''',
)
Loading