Openslide libjpeg error: Wrong JPEG library version - python

I'm working with Openslide's python bindings. I am using Tif images, which are supported by Openslide. It seems I am able to use the methods read_region and get_thumbnail with a smaller, binary masked Tif of about 100 mb's.
However, with a larger, RGBa Tif of about 1.5 Gb, I get the following error:
openslide.lowlevel.OpenSlideError: Wrong JPEG library version: library
is 90, caller expects 80
I have libjpeg8d installed, and everything seems fine with a smaller Tif. Any suggestions on how fix this issue?

I would guess your smaller TIFF is not JPEG-compressed, but your larger one is.
When libtiff starts the jpeg decoder, it checks that the version number in the libjpeg library binary matches the version number in the libjpeg headers that it was compiled against, and if they do not match, it prints the warning you are seeing.
The error means that you have installed a new jpeg library, but not recompiled libtiff or perhaps openslide.
You don't say what platform you are using, but on linux these issues should all be handled for you by your package manager, as long as you stick to the supported versions. If you've built any parts of the system yourself, you'll need to recheck how each part was configured and installed, and how your environment has been set up.

Related

Pillow not detecting the libraqm DLL file

I am having issues with Pillow's text rendering features. I wanted to enable kerning for the font so that it looked nicer, but have descended into an endless rabbit hole of insanity.
When trying to run this code line:
draw.text((1255, 224), desc, font=font.font_variant(size=94), fill=0xff0000ff, features=['kern'])
I receive the following error message:
size, offset = self.font.getsize(
KeyError: 'setting text direction, language or font features is not supported without libraqm'
I've searched online for a long while and have found a few answers that have not yielded any results...
Most notably How to install pre-built Pillow wheel with libraqm DLLs on Windows? and Installing Raqm (Libraqm) Windows 10.
I was so stressed that I eventually copied and pasted the DLL files in every folder I could think of (such as System32, SysWOW64, Python38, Python38\Scripts, Python38\DLLs, etc.), but still failed.
I was even changing PATH, PYTHONPATH, and sys.path.
>>> from PIL import features
>>> features.check('raqm')
False
The check above always printed False
I inspected the code that checks if a feature is present and checked myself, it cannot find any DLL:
>>> imported_module = __import__('PIL._imagingft', fromlist=['PIL'])
>>> vars(imported_module)
{ ..., 'HAVE_RAQM': False, 'HAVE_FRIBIDI': False, 'HAVE_HARFBUZZ': False, ... }
For reference, these are my versions:
Windows 10 Pro 20H2
Pillow 8.2.0
Python 3.8.7
I have become very desperate for any answer... Looked online for a while and was not able to find much information, always only one or two Google results had some relevance to this issue.
I have the same problem
I tried placing libraqm.dll everywhere possible
After googling for days with no hope,
At the end I installed virtualbox and continued my project on Manjaro linux.
I have windows 10 Home
Version 10.0.19042 Build 19042
Pillow 8.2.0
Python 3.9.5

Dump Python sklearn model in Windows and read it in Linux

I am trying to save a sklearn model on a Windows server using sklearn.joblib.dump and then joblib.load the same file on a linux server (centOS71). I get the error below:
ValueError: non-string names in Numpy dtype unpickling
This is what I have tried:
Tried both python27 and python35
Tried the built in open() with 'wb' and 'rb' arguments
I really don't care how the file is moved, I just need to be able to move and load it in a reasonable amount of time.
Python pickle should run between windows/linux. There may be incompatibilities if:
python versions on the two hosts are different (If so, try installing same version of python on both hosts); AND/OR
if one machine is 32-bit and another is 64-bit (I dont know any fix so far for this problem)

Python / Elaphe generates broken barcodes

I am trying to generate code128 barcodes using Python/Elaphe, which is based on Barcode Writer In Pure Postscript (BWIPP). Strangely, the barcodes generated by Elaphe don't match the ones generated by BWIPP and do not conform to code 128 standard.
In particular, I tried a simple example, the generation of a barcode for the letter 'A' (capital A):
from elaphe import barcode
b = barcode('code128', 'A')
b.show()
That works just fine, but the generated barcode is missing the right part. It is 35 pixels wide, where it should be 46. The left part of the barcode matches the one generated by BWIPP and every other code128 generator - it's only the right section that is missing.
Anyone know what's wrong?
(Using elaphe 0.6.0 with python 2.7.10 on Kubuntu 15.10)
See this bug report:
https://bitbucket.org/whosaysni/elaphe/issues/84/code-128-generation-produces-unreadable
It seems that this bug is fixed in the current source version, also the bug is still marked as new.
The the patch which fixed this bug imho:
https://bitbucket.org/whosaysni/elaphe/commits/19dd8f58c76ac75914e3e4d8ae7db1b9489cbcb8?at=develop
This patch is from the 2014-10-22, the current version elaphe 0.6.0 on pypi is from 2013-12-05. If you installed via pip you have the buggy version.
There is a python3 enabled fork of this project https://pypi.python.org/pypi/elaphe3, which was uploaded on the 2016-05-25. So this fork might contain the necessary bugfix. You could remove elaphe and install elaphe3.
However, considering that elaphe (at least the non 3 version) looks pretty abandoned and has GhostScript and PIL as dependencies I would look for another solution.

OpenCV VideoWriter ffmpeg again and again

I know this question was asked hundred of times, nevertheless I got problems.
I'm working on a new windows (2010 server) systen, installed Python 2.7.9 and OpenCV 2.4.10. I copied opencv_ffmpeg.dll to Python27\opencv_ffmpeg2410.dll. I also installed K-Lite video codecs. If I try to save a video with VideoWriter (MJPG), I get always a file with size 5682 bytes which is not playable. On my old system the same python code works, but over the years I installed several versions of drivers and ffmpeg and whatever. So is there a systematic way to get VideoWriter working if you are on a freshly installed system?
Ok, it was my own fault. All the above steps were ok. I made the error to define cv2.VideoWriter(fname,fourcc,2,(w,h),1) with (w,h) different to the actual frame size (I thought it rescales automaticly). Unfortunately there is no appropriate error message.
So my problem is solved.

PIL decoder JPEG not available Raspberry

i'm trying to utilize PIL to open a jpeg image and assign it to a Tkinter's label.
However whenever i try to open the image i get the same problem as this guy
I tried all the suggestions he got and also the ones i found here but it doesn't seem to fix, by installing PIL or Pillow(i tried that too) during the setup i get :
*** TKINTER support not available
*** JPEG support not available
And whenever i run my code i get an IOError: decoder jpeg not available
I'm using python 2.7.
Can someone provide a good method to make PIL or Pillow work with jpeg support? I've been googling extensively for two days, but all the possible fixes that i found don't seem to work for me
Installing libjpeg-dev should do the trick, as proposed by the link you provided. But if it doesn't help (I ran into that as well) you can consider upgrading to Pillow 3, it looks like you are running Pillow 2. This also helped me getting rid of the errors, don't know why exactly..

Categories