mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
fix libtiff in MSYS2
This commit is contained in:
parent
db6253c927
commit
3cabcf242f
5
.github/workflows/test-windows.yml
vendored
5
.github/workflows/test-windows.yml
vendored
|
@ -232,6 +232,7 @@ jobs:
|
|||
mingw-w64-x86_64-libimagequant \
|
||||
mingw-w64-x86_64-libjpeg-turbo \
|
||||
mingw-w64-x86_64-libraqm \
|
||||
mingw-w64-x86_64-libtiff \
|
||||
mingw-w64-x86_64-libwebp \
|
||||
mingw-w64-x86_64-openjpeg2 \
|
||||
subversion
|
||||
|
@ -241,9 +242,7 @@ jobs:
|
|||
pushd depends && ./install_extra_test_images.sh && popd
|
||||
|
||||
- name: Build Pillow
|
||||
run: |
|
||||
# libtiff is unable to open files
|
||||
CFLAGS="-coverage" python3 setup.py build_ext --disable-tiff install
|
||||
run: CFLAGS="-coverage" python3 setup.py build_ext install
|
||||
|
||||
- name: Test Pillow
|
||||
run: |
|
||||
|
|
4
setup.py
4
setup.py
|
@ -710,6 +710,10 @@ class pil_build_ext(build_ext):
|
|||
if feature.tiff:
|
||||
libs.append(feature.tiff)
|
||||
defs.append(("HAVE_LIBTIFF", None))
|
||||
# FIXME the following define should be detected automatically
|
||||
# based on system libtiff, see #4237
|
||||
if PLATFORM_MINGW:
|
||||
defs.append(("USE_WIN32_FILEIO", None))
|
||||
if feature.xcb:
|
||||
libs.append(feature.xcb)
|
||||
defs.append(("HAVE_XCB", None))
|
||||
|
|
|
@ -20,6 +20,17 @@
|
|||
|
||||
#include "TiffDecode.h"
|
||||
|
||||
/* Convert C file descriptor to WinApi HFILE if LibTiff was compiled with tif_win32.c
|
||||
*
|
||||
* This cast is safe, as the top 32-bits of HFILE are guaranteed to be zero,
|
||||
* see https://docs.microsoft.com/en-us/windows/win32/winprog64/interprocess-communication
|
||||
*/
|
||||
#ifndef USE_WIN32_FILEIO
|
||||
#define fd_to_tiff_fd(fd) (fd)
|
||||
#else
|
||||
#define fd_to_tiff_fd(fd) ((int)_get_osfhandle(fd))
|
||||
#endif
|
||||
|
||||
void dump_state(const TIFFSTATE *state){
|
||||
TRACE(("State: Location %u size %d eof %d data: %p ifd: %d\n", (uint)state->loc,
|
||||
(int)state->size, (uint)state->eof, state->data, state->ifd));
|
||||
|
@ -316,7 +327,7 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_
|
|||
if (clientstate->fp) {
|
||||
TRACE(("Opening using fd: %d\n",clientstate->fp));
|
||||
lseek(clientstate->fp,0,SEEK_SET); // Sometimes, I get it set to the end.
|
||||
tiff = TIFFFdOpen(clientstate->fp, filename, mode);
|
||||
tiff = TIFFFdOpen(fd_to_tiff_fd(clientstate->fp), filename, mode);
|
||||
} else {
|
||||
TRACE(("Opening from string\n"));
|
||||
tiff = TIFFClientOpen(filename, mode,
|
||||
|
@ -521,7 +532,7 @@ int ImagingLibTiffEncodeInit(ImagingCodecState state, char *filename, int fp) {
|
|||
|
||||
if (fp) {
|
||||
TRACE(("Opening using fd: %d for writing \n",clientstate->fp));
|
||||
clientstate->tiff = TIFFFdOpen(clientstate->fp, filename, mode);
|
||||
clientstate->tiff = TIFFFdOpen(fd_to_tiff_fd(clientstate->fp), filename, mode);
|
||||
} else {
|
||||
// malloc a buffer to write the tif, we're going to need to realloc or something if we need bigger.
|
||||
TRACE(("Opening a buffer for writing \n"));
|
||||
|
|
Loading…
Reference in New Issue
Block a user