2

I need to be able to convert JPEG-XR images to JPG format, and have gotten this working through ImageMagick itself. However, I need to be able to do this from a python application, and have been looking at using Wand. Wand does not seem to properly use paths to JXR imagery.

with open(os.path.join(args.save_location, img_name[0], result[0]+".jxr"), "wb") as output_file:
    output_file.write(result[1])
    with Image(filename=os.path.join(args.save_location, img_name[0], result[0]+".jxr")) as original:
        with original.convert('jpeg') as converted:
            print(converted.format)
            pass

The first part of this - creating output_file and writing result[1] (blob of JXR imagery from a SQLite database) - works fine. However, when I attempt to then open that newly-saved file as an image using Python and Wand, I get an error that ultimately suggests Wand is not looking in the correct location for the image:

    Extracting panorama 00000
FAILED: -102=pWS->Read(pWS, szSig, sizeof(szSig))
        JXRGlueJxr.c:1806
FAILED: -102=ReadContainer(pID)
        JXRGlueJxr.c:1846
FAILED: -102=pDecoder->Initialize(pDecoder, pStream)
        JXRGlue.c:426
FAILED: -102=pCodecFactory->CreateDecoderFromFile(args.szInputFile, &pDecoder)
        e:\coding\python\sqlite panoramic image extraction tool\jxrlib\jxrencoderdecoder\jxrdecapp.c:477

JPEG XR Decoder Utility
Copyright 2013 Microsoft Corporation - All Rights Reserved

... [it outputs its help page in case of errors; snipped]

The system cannot find the file specified.
Traceback (most recent call last):
  File "E:\Coding\Python\SQLite Panoramic Image Extraction Tool\SQLitePanoramicImageExtractor\trunk\PanoramicImageExtractor.py", line 88, in <module>
    with Image(filename=os.path.join(args.save_location, img_name[0], result[0]+".jxr")) as original:
  File "C:\Python34\lib\site-packages\wand\image.py", line 1991, in __init__
    self.read(filename=filename, resolution=resolution)
  File "C:\Python34\lib\site-packages\wand\image.py", line 2048, in read
    self.raise_exception()
  File "C:\Python34\lib\site-packages\wand\resource.py", line 222, in raise_exception
    raise e
wand.exceptions.BlobError: unable to open image `C:/Users/RPALIW~1/AppData/Local/Temp/magick-14988CnJoJDwMRL4t': No such file or directory @ error/blob.c/OpenBlob/2674

As you can see at the very end, it seems to have attempted to run off to open a temporary file 'C:/Users/RPALIW~1/AppData/Local/Temp/magick-14988CnJoJDwMRL4'. The filename used at this point should be exactly the same as the filename used to save the imagery as a file just a few lines above, but Wand has substituted something else? This looks similar to the last issue I had with this in ImageMagick, which was fixed over the weekend (detailed here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=27027&p=119702#p119702).

Has anyone successfully gotten Wand to open JXR imagery as an Image in Python, and convert to another format? Am I doing something wrong here, or is the fault with ImageMagick or Wand?

RebeccaP
  • 43
  • 5

1 Answers1

0

Something very similar is happening to me. I'm getting an error:

wand.exceptions.BlobError: unable to open image `/var/tmp/magick-454874W--g1RQEK3H.ppm': No such file or directory @ error/blob.c/OpenBlob/2701

The path given is not the file path I of the image I am trying to open.

From the docs:

A binary large object could not be allocated, read, or written.

And I am trying to open a large file. (18mb .cr). Could the file size be the problem?

For me:

from wand.image import Image as WImage

with open(file_name, 'r+') as f:
    with WImage(file = f) as img:
        print 'Opened large image'

Or:

with open(file_name, 'r+') as f:
    image_binary = f.read()

    with WImage(blob = image_binary) as img:
        print 'Opened Large Image'

Did the trick

~Victor

VFR292
  • 89
  • 1
  • 7