mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 10:16:17 +03:00
Added precinct size option. Also added the jp2klib_version symbol on the _imaging module.
This commit is contained in:
parent
5cb73c94e9
commit
9a1b6966b5
|
@ -196,6 +196,7 @@ def _save(im, fp, filename):
|
|||
quality_layers = info.get('quality_layers', None)
|
||||
num_resolutions = info.get('num_resolutions', 0)
|
||||
cblk_size = info.get('codeblock_size', None)
|
||||
precinct_size = info.get('precinct_size', None)
|
||||
irreversible = info.get('irreversible', False)
|
||||
progression = info.get('progression', 'LRCP')
|
||||
cinema_mode = info.get('cinema_mode', 'no')
|
||||
|
@ -212,6 +213,7 @@ def _save(im, fp, filename):
|
|||
quality_layers,
|
||||
num_resolutions,
|
||||
cblk_size,
|
||||
precinct_size,
|
||||
irreversible,
|
||||
progression,
|
||||
cinema_mode,
|
||||
|
|
|
@ -3461,6 +3461,13 @@ setup_module(PyObject* m) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENJPEG
|
||||
{
|
||||
extern const char *ImagingJpeg2KVersion(void);
|
||||
PyDict_SetItemString(d, "jp2klib_version", PyUnicode_FromString(ImagingJpeg2KVersion()));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
/* zip encoding strategies */
|
||||
PyModule_AddIntConstant(m, "DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY);
|
||||
|
|
10
encode.c
10
encode.c
|
@ -836,7 +836,7 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args)
|
|||
char *quality_mode = "rates";
|
||||
PyObject *quality_layers = NULL;
|
||||
int num_resolutions = 0;
|
||||
PyObject *cblk_size = NULL;
|
||||
PyObject *cblk_size = NULL, *precinct_size = NULL;
|
||||
PyObject *irreversible = NULL;
|
||||
char *progression = "LRCP";
|
||||
OPJ_PROG_ORDER prog_order;
|
||||
|
@ -844,10 +844,11 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args)
|
|||
OPJ_CINEMA_MODE cine_mode;
|
||||
int fd = -1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss|OOOsOIOOssi", &mode, &format,
|
||||
if (!PyArg_ParseTuple(args, "ss|OOOsOIOOOssi", &mode, &format,
|
||||
&offset, &tile_offset, &tile_size,
|
||||
&quality_mode, &quality_layers, &num_resolutions,
|
||||
&cblk_size, &irreversible, &progression, &cinema_mode,
|
||||
&cblk_size, &precinct_size,
|
||||
&irreversible, &progression, &cinema_mode,
|
||||
&fd))
|
||||
return NULL;
|
||||
|
||||
|
@ -916,6 +917,9 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args)
|
|||
j2k_decode_coord_tuple(cblk_size,
|
||||
&context->cblk_width,
|
||||
&context->cblk_height);
|
||||
j2k_decode_coord_tuple(precinct_size,
|
||||
&context->precinct_width,
|
||||
&context->precinct_height);
|
||||
|
||||
context->irreversible = PyObject_IsTrue(irreversible);
|
||||
context->progression = prog_order;
|
||||
|
|
|
@ -65,6 +65,9 @@ typedef struct {
|
|||
/* Code block size */
|
||||
int cblk_width, cblk_height;
|
||||
|
||||
/* Precinct size */
|
||||
int precinct_width, precinct_height;
|
||||
|
||||
/* Compression style */
|
||||
int irreversible;
|
||||
|
||||
|
|
|
@ -364,6 +364,15 @@ j2k_encode_entry(Imaging im, ImagingCodecState state,
|
|||
params.cblockh_init = context->cblk_height;
|
||||
}
|
||||
|
||||
if (context->precinct_width >= 4 && context->precinct_height >= 4
|
||||
&& context->precinct_width >= context->cblk_width
|
||||
&& context->precinct_height > context->cblk_height) {
|
||||
params.prcw_init[0] = context->precinct_width;
|
||||
params.prch_init[0] = context->precinct_height;
|
||||
params.res_spec = 1;
|
||||
params.csty |= 0x01;
|
||||
}
|
||||
|
||||
params.irreversible = context->irreversible;
|
||||
|
||||
params.prog_order = context->progression;
|
||||
|
|
Loading…
Reference in New Issue
Block a user