Skip to content

Commit 0216c44

Browse files
committed
Fixing issue #154
1 parent 4c22889 commit 0216c44

File tree

9 files changed

+40
-42
lines changed

9 files changed

+40
-42
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ script:
4646
- cibuildwheel --output-dir wheelhouse
4747

4848
before_deploy:
49-
- git tag "v1.12.5"
49+
- git tag "v1.12.6"
5050
deploy:
5151
provider: releases
5252
api_key:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PyMuPDF 1.12.5 [![Build Status](https://travis-ci.org/rk700/PyMuPDF.svg?branch=master)](https://travis-ci.org/rk700/PyMuPDF)
1+
# PyMuPDF 1.12.6 [![Build Status](https://travis-ci.org/rk700/PyMuPDF.svg?branch=master)](https://travis-ci.org/rk700/PyMuPDF)
22

33
![logo](https://github.com/rk700/PyMuPDF/blob/master/demo/pymupdf.jpg)
44

@@ -10,7 +10,7 @@ Release date: January 15, 2018
1010

1111
# Introduction
1212

13-
This is **version 1.12.5 of PyMuPDF (formerly python-fitz)**, a Python binding which supports [MuPDF 1.12](http://mupdf.com/) - "a lightweight PDF and XPS viewer".
13+
This is **version 1.12.6 of PyMuPDF (formerly python-fitz)**, a Python binding which supports [MuPDF 1.12](http://mupdf.com/) - "a lightweight PDF and XPS viewer".
1414

1515
MuPDF can access files in PDF, XPS, OpenXPS, CBZ, EPUB and FB2 (e-books) formats, and it is known for its top performance and high rendering quality.
1616

doc/PyMuPDF.pdf

264 Bytes
Binary file not shown.

doc/html.zip

-247 Bytes
Binary file not shown.

fitz/fitz.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class _object:
102102

103103

104104
VersionFitz = "1.12.0"
105-
VersionBind = "1.12.5"
106-
VersionDate = "2018-03-29 10:50:05"
107-
version = (VersionBind, VersionFitz, "20180329105005")
105+
VersionBind = "1.12.6"
106+
VersionDate = "2018-04-02 05:04:08"
107+
version = (VersionBind, VersionFitz, "20180402050408")
108108

109109

110110
#------------------------------------------------------------------------------

fitz/fitz_wrap.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,36 +3241,35 @@ DG_print_stext_image_as_json(fz_context *ctx, fz_output *out, fz_stext_block *bl
32413241
DG_print_rect_json(ctx, out, &(block->bbox));
32423242
fz_image *image = block->u.i.image;
32433243
fz_buffer *buf = NULL;
3244+
fz_compressed_buffer *buffer = NULL;
3245+
int n = fz_colorspace_n(ctx, image->colorspace);
32443246
int w = image->w;
32453247
int h = image->h;
32463248
int bparams = 0;
3247-
fz_compressed_buffer *buffer = fz_compressed_image_buffer(ctx, image);
3249+
buffer = fz_compressed_image_buffer(ctx, image);
32483250
if (buffer) bparams = buffer->params.type;
32493251
fz_write_printf(ctx, out, "\n \"imgtype\": %d, \"width\": %d, \"height\": %d, ",
32503252
bparams, w, h);
32513253
fz_write_printf(ctx, out, "\"image\":\n");
32523254

3253-
if (!buffer)
3255+
if (bparams == FZ_IMAGE_JPEG && (n == 1 || n == 3) ||
3256+
bparams == FZ_IMAGE_PNG)
32543257
{
3255-
fz_try(ctx)
3256-
{
3257-
buf = fz_new_buffer_from_image_as_png(ctx, image, NULL);
3258-
fz_write_printf(ctx, out, "\"");
3259-
fz_write_base64_buffer(ctx, out, buf, 0);
3260-
fz_write_printf(ctx, out, "\"");
3261-
}
3262-
fz_always(ctx) fz_drop_buffer(ctx, buf);
3263-
fz_catch(ctx)
3264-
{
3265-
fz_write_printf(ctx, out, "null");
3266-
}
3258+
fz_write_printf(ctx, out, "\"");
3259+
fz_write_base64_buffer(ctx, out, buffer->buffer, 0);
3260+
fz_write_printf(ctx, out, "\"");
3261+
fz_write_printf(ctx, out, "\n }");
3262+
return;
32673263
}
3268-
if (buffer)
3264+
fz_try(ctx)
32693265
{
3266+
buf = fz_new_buffer_from_image_as_png(ctx, image, NULL);
32703267
fz_write_printf(ctx, out, "\"");
3271-
fz_write_base64_buffer(ctx, out, buffer->buffer, 0);
3268+
fz_write_base64_buffer(ctx, out, buf, 0);
32723269
fz_write_printf(ctx, out, "\"");
32733270
}
3271+
fz_always(ctx) fz_drop_buffer(ctx, buf);
3272+
fz_catch(ctx) fz_write_printf(ctx, out, "null");
32743273
fz_write_printf(ctx, out, "\n }");
32753274
}
32763275

fitz/helper-stext.i

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,36 +55,35 @@ DG_print_stext_image_as_json(fz_context *ctx, fz_output *out, fz_stext_block *bl
5555
DG_print_rect_json(ctx, out, &(block->bbox));
5656
fz_image *image = block->u.i.image;
5757
fz_buffer *buf = NULL;
58+
fz_compressed_buffer *buffer = NULL;
59+
int n = fz_colorspace_n(ctx, image->colorspace);
5860
int w = image->w;
5961
int h = image->h;
6062
int bparams = 0;
61-
fz_compressed_buffer *buffer = fz_compressed_image_buffer(ctx, image);
63+
buffer = fz_compressed_image_buffer(ctx, image);
6264
if (buffer) bparams = buffer->params.type;
6365
fz_write_printf(ctx, out, "\n \"imgtype\": %d, \"width\": %d, \"height\": %d, ",
6466
bparams, w, h);
6567
fz_write_printf(ctx, out, "\"image\":\n");
6668

67-
if (!buffer)
69+
if (bparams == FZ_IMAGE_JPEG && (n == 1 || n == 3) ||
70+
bparams == FZ_IMAGE_PNG)
6871
{
69-
fz_try(ctx)
70-
{
71-
buf = fz_new_buffer_from_image_as_png(ctx, image, NULL);
72-
fz_write_printf(ctx, out, "\"");
73-
fz_write_base64_buffer(ctx, out, buf, 0);
74-
fz_write_printf(ctx, out, "\"");
75-
}
76-
fz_always(ctx) fz_drop_buffer(ctx, buf);
77-
fz_catch(ctx)
78-
{
79-
fz_write_printf(ctx, out, "null");
80-
}
72+
fz_write_printf(ctx, out, "\"");
73+
fz_write_base64_buffer(ctx, out, buffer->buffer, 0);
74+
fz_write_printf(ctx, out, "\"");
75+
fz_write_printf(ctx, out, "\n }");
76+
return;
8177
}
82-
if (buffer)
78+
fz_try(ctx)
8379
{
80+
buf = fz_new_buffer_from_image_as_png(ctx, image, NULL);
8481
fz_write_printf(ctx, out, "\"");
85-
fz_write_base64_buffer(ctx, out, buffer->buffer, 0);
82+
fz_write_base64_buffer(ctx, out, buf, 0);
8683
fz_write_printf(ctx, out, "\"");
8784
}
85+
fz_always(ctx) fz_drop_buffer(ctx, buf);
86+
fz_catch(ctx) fz_write_printf(ctx, out, "null");
8887
fz_write_printf(ctx, out, "\n }");
8988
}
9089

fitz/version.i

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%pythoncode %{
22
VersionFitz = "1.12.0"
3-
VersionBind = "1.12.5"
4-
VersionDate = "2018-03-29 10:50:05"
5-
version = (VersionBind, VersionFitz, "20180329105005")
3+
VersionBind = "1.12.6"
4+
VersionDate = "2018-04-02 05:04:08"
5+
version = (VersionBind, VersionFitz, "20180402050408")
66
%}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
sources=['./fitz/fitz_wrap.c',])
5858

5959
setup(name = 'PyMuPDF',
60-
version = "1.12.5",
60+
version = "1.12.6",
6161
description = 'Python bindings for the PDF rendering library MuPDF',
6262
classifiers = ['Development Status :: 5 - Production/Stable',
6363
'Environment :: Console',

0 commit comments

Comments
 (0)