1
0
Fork 0
forked from josch/img2pdf
Commit graph

261 commits

Author SHA1 Message Date
d931f02709
src/tests/__init__.py: handle PNG input images properly 2018-07-18 00:05:15 +02:00
b99fae1380
src/tests/__init__.py: don't test for color space now that we support palette PNGs 2018-07-18 00:04:30 +02:00
ac9ba1d0f6
handle monochrome png properly 2018-07-18 00:03:31 +02:00
eaf9de23c9
Filter must not be array for PNG output, so never make it an array 2018-07-17 23:59:55 +02:00
2a33ff275d
adapt test output to new handling of png input 2018-07-17 23:56:01 +02:00
ebd8d911bb
add test grayscale input png src/tests/input/gray.png 2018-07-17 16:57:44 +02:00
e7755f0a87
src/tests/input/normal.png: remove alpha channel 2018-07-17 16:57:44 +02:00
47a1e0c81e
src/img2pdf.py: do not use PNG encoding for CMYK input 2018-07-17 16:57:44 +02:00
3142824bab
src/tests/__init__.py: do not test animation.gif with pdfrw because it doesn't support hexadecimal palette data 2018-07-17 16:57:44 +02:00
84ce9bbd9c
src/img2pdf.py: do not allow transparency 2018-07-17 16:57:44 +02:00
90293204b2
src/img2pdf.py: use logging.warning because warn() is deprecated 2018-07-17 16:07:01 +02:00
ade5768d72
src/img2pdf.py: expand error message about alpha channel 2018-03-27 10:39:24 +02:00
920506b867
Reflect the fact that we now use PNG compression in the --help output 2018-03-24 19:53:41 +01:00
e78dd80451
Add option --pillow-limit-break to force Pillow to accept large input images 2018-03-24 19:47:03 +01:00
d9a6c9db03
Interlaced PNGs cannot be directly embedded but have to be re-encoded 2018-03-24 18:59:02 +01:00
7244d2c6ed
Disallow input images with alpha channel as it cannot be preserved in the PDF and would thus make img2pdf not lossless 2018-03-24 18:55:14 +01:00
1d9a25dfd2
Proof of concept of using PDF DecodeParms for storing pixel data with PNG compression 2018-03-15 11:31:36 +01:00
9836b976d3 src/img2pdf.py: handle Pillow returning a DPI of zero (closes: #36) 2017-10-18 10:34:59 +02:00
James R. Barlow
a8269391e9 Implement /UserUnit scaling to support oversized PDFs
The original PDF specification supported a maximum of 200x200" pages or
14400 PDF units. In PDF 1.6 rather than remove this limitation, Adobe
added the /UserUnit field for pages, which allows one to specify the
scaling that should be applied for user-facing numbers, while keeping
the internal limit of 14400 units.

Many real-world designs are larger than 200" in one direction. One
example is tractor feed or rolled paper which may be easier to scan in
one continuous run rather than segment into pages.

/UserUnit is independent of the pixel size and resolution of the image.

/UserUnit can also indicate very small page sizes but this is not
implemented here.
2017-08-20 21:19:23 +09:00
James R. Barlow
b54617de19 Fix rawdata[:12] bytes/str comparison 2017-08-20 21:11:32 +09:00
Adam Groszer
0e76a5bd97 fixing a slew of python 2 issues 2017-08-07 11:21:42 +02:00
725462462b release version 0.2.4 2017-05-23 17:53:19 +02:00
Stephan Richter
f626d7860f Produce port that is fully API compatible. 2017-05-23 17:51:17 +02:00
Stephan Richter
06560cd0d4 It is easy enough to create a separate class for the Py2 version. 2017-05-22 19:34:39 +02:00
Stephan Richter
719928f5f5 Declare file encoding, since it contains some non-ascii chars. 2017-05-22 19:34:39 +02:00
Stephan Richter
b25098c3f0 Python 2 does not automatically convert integers to floats, so we have to be a bit more explicit. 2017-05-22 19:34:34 +02:00
Stephan Richter
18d637ea34 Make sure we are using the correct IO class in Python 2. 2017-05-22 12:31:52 -04:00
16993964ce restore pep8 compliance 2017-01-20 09:19:30 +01:00
7df29a9acc Allow to call get_layout_fun with less parameters by specifying defaults 2017-01-20 09:15:02 +01:00
60b2e2206a Add multiframe gif (animated gif) test case 2017-01-20 08:48:16 +01:00
8476e333cd src/tests/__init__.py: add support for multiframe gif tests 2017-01-20 08:47:58 +01:00
e20fe4944c release version 0.2.3 2017-01-20 05:47:06 +01:00
1513ab3421 release version 0.2.2 2017-01-20 05:23:40 +01:00
4040e907a3 Make --help output more friendly to help2man 2017-01-20 05:17:23 +01:00
ef36e86a46 Fix default of --producer argument in --help output to include version 2017-01-20 04:46:26 +01:00
e4b6854eb5 src/tests/output/mono.png.pdf: remove the /Producer field 2017-01-20 04:45:30 +01:00
fbeecd2301 Allow to not add the /Producer field to the metadata 2017-01-20 04:45:14 +01:00
f94684c8ea If input to convert() doesn't have a write() member, then it must be str or bytes type 2017-01-19 20:32:46 +01:00
7c90b2c451 restore backwards compatibility and allow passing images as a list 2017-01-19 20:32:16 +01:00
962d4dbdfb Make pep8 compliant again 2017-01-19 11:22:08 +01:00
c2f43a579e src/tests/output/mono.png.pdf: remove timestamps 2017-01-19 09:02:16 +01:00
James R. Barlow
eedf73e73e Add test cases for CCITT G4 2016-07-22 07:09:35 +02:00
James R. Barlow
c27505486e Break out TIFF G4 transcoding into its own function 2016-07-22 07:09:24 +02:00
James R. Barlow
95f84f97bc Implement automatic monochrome CCITT Group4 encoding via Pillow/libtiff 2016-07-22 07:09:07 +02:00
Jakub Wilk
0fe30a62d9 fix typos 2016-06-10 17:02:38 +01:00
e05d2992e0 src/tests/__init__.py: adapt testcases for last commit 2016-05-26 18:11:42 +02:00
d78b2cbdbc Fix bug where horizontal and vertical borders where switched when page size was also given. Thanks Erik./a.out| sox -c 1 -e unsigned-integer -r 8000 -t u8 - -d --buffer 32 Closes #30 2016-05-26 08:19:34 +02:00
Andrey Gursky
c704e657cc update version according to release 2016-05-11 21:39:21 +02:00
c158585618 only use jp2 to parse jpeg2000 if PIL doesn't support jpeg2000 2016-02-17 20:31:46 +01:00
e5b0ffee6c read horizontal and vertical dpi from jpeg2000 files 2016-02-17 20:30:58 +01:00
ef9eac7326 instead of storing a limited list of supported colorspaces and imageformats, store the items requiring special treatment but do not abort if a value other than the listed ones is supported by PIL 2016-02-17 18:47:02 +01:00
00c73a6691 make the separating x optional when specifying the width without the height 2016-02-17 18:16:17 +01:00
86552a78dc fix --fit=exact if one value is missing 2016-02-17 18:11:11 +01:00
ad528d4feb restore feature that it is allowed to only specify width or height 2016-02-17 17:51:57 +01:00
3e8894c7da change MonochromeJpegError to JpegColorspaceError and add check for jpegs with alpha channel 2016-02-17 00:37:51 +01:00
d9b2550ceb support for palette images for better GIF support 2016-02-17 00:37:51 +01:00
edba669000 support from multi-frame images like multipage TIFF and animated GIF 2016-02-17 00:37:46 +01:00
dbed55655a fix JPEG2000 handling after move to Python3 2016-02-17 00:28:19 +01:00
27015c1a6e fix testsuite after exception renaming 2016-02-17 00:26:45 +01:00
c6d69b231b when verbose logging is enabled, print a traceback of possibly raised exceptions 2016-02-14 18:55:27 +01:00
b6e969d267 input images can now be file like objects, binary strings with the image content or filenames 2016-02-14 18:54:59 +01:00
cc59fbc3e4 raise exceptions instead of doing an exit() 2016-02-13 09:31:33 +01:00
James R. Barlow
900346d430 src/img2pdf.py: add get_fixed_dpi_layout_fun 2016-02-13 09:01:08 +01:00
James R. Barlow
a7dba2894f Put version string in /Producer too 2016-02-13 09:01:03 +01:00
James R. Barlow
11affb6264 allow writing the pdf to a file-like object instead of storing everything in memory 2016-02-13 09:00:53 +01:00
31a2ce231f cap the maximum page size at 200 dpi which is the maximum supported by PDF 2016-02-10 09:44:12 +01:00
7160f1628d fix parsing of dpi and % units 2016-02-10 09:32:38 +01:00
917c173bfd set img2pdf as default /producer value 2016-02-10 07:25:55 +01:00
josch
251238b410 release version 0.2.0 - big rewrite and lots of new features
- now Python3 only
 - pep8 compliant code
 - update my email to josch@mister-muffin.de
 - move from github to gitlab.mister-muffin.de/josch/img2pdf
 - use logging module
 - add extensive test suite
 - ability to read from standard input
 - pdf writer:
      - make more compatible with the interface of pdfrw module
      - print floats which equal to their integer conversion as integer
      - do not print trailing zeroes for floating point numbers
      - print more linebreaks
      - add binary string at beginning of PDF to indicate that the PDF
        contains binary data
      - handle datetime and unicode strings by using utf-16-be encoding
 - new options (see --help for more details):
      - --without-pdfrw
      - --imgsize
      - --border
      - --fit
      - --auto-orient
      - --viewer-panes
      - --viewer-initial-page
      - --viewer-magnification
      - --viewer-page-layout
      - --viewer-fit-window
      - --viewer-center-window
      - --viewer-fullscreen
 - remove short command line options for metadata arguments
2016-02-02 19:51:27 +01:00
josch
33ee44e50d restore python3 compatibility 2015-04-12 20:37:57 +02:00
josch
18a41fc8df avoid catch-all except 2015-03-21 10:01:56 +01:00
josch
4968d58621 fix typo 2015-03-21 10:01:56 +01:00
josch
f3674907d6 store times in UTC and understand YYYY-MM-DD, YYYY-MM-DDTHH:MM, YYYY-MM-DDTHH:MM:SS and everything understood by dateutil module and date --date 2015-03-21 10:01:56 +01:00
josch
81647dd06f use common variable for datetime format string 2015-03-21 10:01:56 +01:00
josch
5a1f0701a3 to allow non-ascii characters, encode strings as utf-16-be (big endian) and escape backslashes and parenthesis 2015-03-21 10:01:56 +01:00
josch
317a0ee7f2 do not encode as utf8 as pdf is ascii, add safer handling across py2/py3 2015-03-21 10:01:56 +01:00
xiota
592cdc1cdb Changes to pdf page size handling
Changes to `valid_size()`
* accept common page sizes, such as letter and a4.
* parse dimensions of format: AuxBv#, where A is width, u is units, B is height, v is units, # are options.
* accept units: in, cm, mm, pt

Changes to `convert()`:
* resize pages based on dpi calculations
* default resize images into page size (like default resize in imagemagick)
* implement exact resizing (ignore dpi; equiv to ! in imagemagick)

Created `get_ndpi()`:
* provides dpi for page resizing
* implement fill resizing (equiv to ^ in imagemagick)

Other changes:
* default dpi in global variable
2015-03-20 06:54:11 -07:00
josch
36fb9173fe add --version option and __version__ module variable and use ~git version suffix 2015-03-07 03:20:14 +01:00
josch
d5fc324b7b cater for python-pil versions without close() attribute (the 3rd fix) 2015-03-07 03:02:00 +01:00
josch
b90e385efe cater for python-pil versions without close() attribute (the 2nd fix) 2015-03-07 03:01:02 +01:00
josch
486361e716 cater for python-pil versions without close() attribute 2015-03-07 02:59:12 +01:00
josch
9389d81a14 fix testsuite after commit 2cb8e55f broke it - thanks Jakub Wilk! 2015-03-06 23:55:32 +01:00
Jakub Wilk
5d7975164d remove unused imports 2015-03-06 22:51:58 +01:00
josch
53968c31e0 remove -x and -y and replace by -s/--pagesize. Change short option for --subject to -S. 2015-03-06 19:29:24 +01:00
josch
ad8567d352 add more details to code comment 2015-03-06 19:19:21 +01:00
josch
2cb8e55f1d output pdf image size with four significant digits 2015-03-06 19:16:36 +01:00
josch
aabd104114 update tests handling 2015-02-16 19:23:21 +01:00
josch
4d005c8443 write to sys.stdout.buffer and fall back to sys.stdout 2015-02-16 19:20:06 +01:00
josch
e810f3baf4 close cStringIO and PIL.Image 2015-02-16 19:19:49 +01:00
josch
90e954dc0a make sure dpi are read as integers and divided using float division 2015-02-16 19:18:46 +01:00
josch
8887fe21f4 print floats with four decimal places 2015-02-16 19:09:34 +01:00
josch
9ff6ebec04 pass on --nodate option 2015-02-16 14:49:53 +01:00
josch
3fdd824201 support file objects as input 2015-02-16 14:49:29 +01:00
josch
18ca3b4491 make 2nd, 3rd and 4th argument optional by supplying None as default 2015-02-16 07:15:10 +01:00
Erik Jensen
c68ce6a48d Add CMYK test images 2015-02-16 07:09:38 +01:00
Erik Jensen
e4db4e9e8e Enable support for CMYK images
CMYK TIFFs and JPEGs both work. CMYK JPEG2000 images have not been
tested. Adobe Photoshop and some other software generate inverted CMYK
JPEGs. The image is assumed to be inverted if the "Adobe" (APP14) tag is
present. Images can be forced inverted with `-C "CMYK;I"`, and forced
not inverted with `-C CMYK`.
2015-02-16 07:09:38 +01:00
lukahn
5c7753d6c4 Fix for adding custom resolutions 2015-01-15 16:15:05 +11:00
josch
700e62f1d8 make output reproducible by sorting and --nodate option 2015-01-07 16:23:52 +01:00
josch
b143867a72 add Python 3 support 2015-01-07 15:56:24 +01:00
josch
d8a11d839c fix problem with conversion of closed file 2014-11-10 10:13:52 +01:00
Ryan C. Thompson
d09cd0f197 Use "with" to open and close input files 2014-11-06 00:53:16 -08:00
Ryan C. Thompson
b726afbb5a Convert unrecognized colorspaces to RGB
Instead of crashing on an unrecognized colorspace, we now do
imgdata.convert('RGB').
2014-11-05 23:47:42 -08:00
Ryan C. Thompson
c76f1344a5 Avoid leaking file descriptors
This change prevents img2pdf from opening *all* input files at once,
which means it now works with thousands of input files.
2014-11-05 23:46:47 -08:00
josch
0bdf6472f8 fix regression introduced by 9b35f5cf 2014-08-24 17:15:43 +02:00
xiota
9b35f5cf6b add options to specify pdf dimensions in points
add options specify output pdf dimensions in points:  -x width;  -y height.
2014-08-04 11:25:07 -04:00
Nicolas ELIE
563bcb0372 Added python shebang
Added python shebang to be able to launch script directly
2014-07-26 16:12:40 +02:00
Felix Bünemann
a3046ca771 Add pillow 2.4.0 support
Pillow 2.4.0 added support for JPEG2000 using OpenJPEG 2.0. Because
Pillow calls the format JPEG2000 instead of JP2, we need to rename it to
enable the optimized code path. Should still be backwards compatible.
2014-04-05 01:55:03 +02:00
josch
818db1902f license change from GPL to LGPL 2014-03-30 08:10:12 +02:00
josch
632cd1d712 allow running src/img2pdf.py standalone 2014-03-14 19:18:38 +01:00
Stephan Richter
db7e74bcfe Added tests for the package. 2014-03-14 19:18:38 +01:00
Stephan Richter
b47cc04dd3 Start of converting the module to a proper package. 2014-03-14 19:18:31 +01:00