JPEG-2000 problems

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
so0ly

JPEG-2000 problems

Post by so0ly »

Hi, i'm experiencing some problems with the JPEG-2000 file format and Imagemagick.

First of all i needed to identify a jpf file, i couldn't get this to work after lots of tries, any idea if this is supported? I always got following error:

Code: Select all

# identify -format "%m" Schutters_1.jpf 
error: cannot decode code stream
identify: unable to decode image file `Schutters_1.jpf' @ jp2.c/ReadJP2Image/403.
Because the jpf didn't work i wanted to find out why, that's why i started testing .jp2 files. These files do work when i execute them as root, but when i do this as another user, or the www-user (for a php project) it doesn't work (while identifying a jpeg or png does work). I get following error:

Code: Select all

$ identify -format "%m" /tmp/seq-1.jp2 
error: cannot decode code stream
identify: unable to decode image file `/tmp/seq-1.jp2' @ error/jp2.c/ReadJP2Image/400.
I think it's using some external plugin or something on which i don't have enough permissions, but i don't know which one.

Does anyone have any experience with these kinds of files?

These are the files:
http://users.telenet.be/so0ly/Schutters_1.jpf
http://users.telenet.be/so0ly/seq-1.jp2

I also checked other topics and these are the delegates of my configuration:
DELEGATES bzlib djvu fontconfig freetype gvc jpeg jng jp2 lcms mpeg openexr png rsvg tiff x11 xml wmf zlib

greets,
Daan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG-2000 problems

Post by fmw42 »

never heard of jpf format. did you mistype and mean jpg?

jpg is normal jpg

jp2 is jpeg-2000 and is controlled by the jasper delegate library (you can google for it)

since jp2 shows in your Delegate library list, you have jasper installed, but you might check its version and upgrade if necessary. Same for the libjpg delegate library

You might upgrade IM, too, after reinstalling any delegates. You need to reinstall if you install any new delegates.

You never mentioned what IM version and platform.

Your jp2 file opens fine in my IM 6.6.3.9 Q16 Mac OSX Tiger.

Your jpf file opens as a text file with garbage. So it is binary, but my system does not know how to read it.

However, if you download it and just change the suffix to jp2 or to jpg, then it opens fine. Though it has a redish-color tint to it.

You can see all the file types that IM supports on your system config by

convert -list format

On my system, there is no jpf.
so0ly

Re: JPEG-2000 problems

Post by so0ly »

Well i also never heard of the jpf file format until today :)
but from what i understand it is an extension to the standard JPEG-2000, it's supposed to be the same as jpx.

I indeed forgot to specify which ImageMagick version i'm using (stupid me), i was testing on two machines with two different IM setups:

Code: Select all

Version: ImageMagick 6.5.7-8 2009-11-26 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: OpenMP 

Code: Select all

Version: ImageMagick 6.6.2-10 2010-07-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP 
The delegates where already installed, in fact the jp2 fileformat just works, when executing the identify command as root user, this has problems with my www-data user for the php projects. The jpf format just doesn't work.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG-2000 problems

Post by fmw42 »

The delegates where already installed, in fact the jp2 fileformat just works, when executing the identify command as root user, this has problems with my www-data user for the php projects. The jpf format just doesn't work.
IM does not recognize jpf or jpx. So you have to use jp2, as far as I know. Perhaps there is some IM config file you can change to add jpf or jpx so that the jasper delegate library knows about it.

Can you open the jpf file with jasper in standalone mode?

With respect to using it in PHP, can you get your php code to work with any other image format? PHP usually requires that you specify the full path to the convert or identify command.


This should tell you the path to IM

<?php
exec("which convert",$out,$returnval);
print_r($out[0]);
?>

Change the full path and try:

<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

Then try

<?php
exec("/usr/local/bin/identify rose:",$out,$returnval);
print_r($out[0]);
?>

Then put in your various other image formats, such as gif,png,jpg,jp2. See if those work.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG-2000 problems

Post by fmw42 »

You might be able to add a line in coder.xml in the config directory of your source code to make jpf the same as jp2, then recompile. But I would get expert opinion on this before doing so. Or easier just edit it in your installed files, such as in /usr/local/share/ImageMagick-6.6.3/config/coder.xml (on my system)
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: JPEG-2000 problems

Post by Drarakel »

These are probably two different problems..
Regarding your problem with 'seq-1.jp2':
I don't know much about Unix environments, so someone else may help you better here. But just some thoughts: Maybe you have different installations of ImageMagick, and with different user accounts, you get different versions? Or maybe the paths variables are different with the users. Or something else that restricts ImageMagick from using jasper..?
Maybe Fred already gave you the essential hints here.

Regarding 'Schutters_1.jpf':
ImageMagick already identifies that as JP2 file. But with IM/jasper, this special file can't be decoded. I can open it on Windows with e.g. IrfanView with no errors. With XnView (which also uses jasper), this image again can't be opened. So, it seems to be a problem within jasper.(?)
so0ly

Re: JPEG-2000 problems

Post by so0ly »

I'm already using the latest version of Jasper

Code: Select all

1.900.1
libjasper 1.900.1
The redish-color tint on the image is right.

When i do convert -list format i'm also not seeing jpf, but jpx is in it:

Code: Select all

JP2* JP2       rw-   JPEG-2000 File Format Syntax
      JPC* JPC       rw-   JPEG-2000 Code Stream Syntax
     JPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (62)
      JPG* JPEG      rw-   Joint Photographic Experts Group JFIF format (62)
      JPX* JPX       rw-   JPEG-2000 File Format Syntax
If jpf isn't supported by ImageMagick then that is no problem :) i just wanted to know. But jp2 has to work. I can just batch process my jpf files to jpg.

Using the standalone jasper also doesn't work for jpf. I can't convert the jpf to jpg. But converting the jp2 to jpg did work.

The php code is working for every simple file format: png, jpg, gif ... no problem for these only jp2 didn't work. I'm using the full path to the identify program. So i don't think i'm using different installations for different users. I think it has something to do with jasper that tries to do something where i don't have enough permissions for or so.

I can also open the jpf file using Quicktime.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG-2000 problems

Post by fmw42 »

If jpf isn't supported by ImageMagick then that is no problem i just wanted to know. But jp2 has to work. I can just batch process my jpf files to jpg.
Your jpf image works fine, if you just first change the suffix to .jp2

Also your jp2 image worked fine for me.

You can probably also modify the coder.xml file to add jpf as an alternate to jp2
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: JPEG-2000 problems

Post by Drarakel »

fmw42 wrote:Your jpf image works fine, if you just first change the suffix to .jp2
Doesn't work for me. What version of jasper is used on your system?
With my standard installation of the ImageMagick Q16 binary for Windows, this file is always identified as some JP2 format (as jp2.c is used), but can't get decoded - regardless of the extension. The jasper version in the Windows binary is also v1.900.1, I think (but not sure).
Another possibility would be a resource problem. But the file is only A4 - so I can't believe that it's too big..
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG-2000 problems

Post by fmw42 »

On my Mac (IM 6.6.3.9 Q16),

JasPer Transcoder (Version 1.900.1) installed via MacPorts which install all needed delegates for it.

Perhaps there is some other delegate needed to be upgraded to support Jasper?

MacPorts reports:


jasper 1.900.1
Library for manipulating JPEG-2000 images
Maintained by: jmr openmaintainer
Categories: graphics
Platforms: darwin
Dependencies: jpeg
Variants: jiv universal


So only a current version of jpeg is needed. Try upgrading your jpeg delegate first ( libjpeg?)

see http://www.ijg.org/
or
http://freshmeat.net/projects/libjpeg/
so0ly

Re: JPEG-2000 problems

Post by so0ly »

I already have the latest version if libjpeg installed. Just tested it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG-2000 problems

Post by fmw42 »

fmw42 wrote:
Your jpf image works fine, if you just first change the suffix to .jp2
Clarification:

If I just change the suffix from jpf to jp2, then Mac Preview opens it just fine. IM display on unix does not. If I leave it as jpf, then the Max app GraphicConverter opens it fine.

With regard to the jp2 image, that also opens just fine in Mac Preview, but not in IM display.

Sorry for the confusion. I only use the IM display for formats that Mac Preview does not understand.
so0ly

Re: JPEG-2000 problems

Post by so0ly »

i tried debugging the identify method of the jp2 file with "identify -debug all seq-1.jp2".

Code: Select all

2010-08-31T09:38:58+02:00 0:00.000 0.000u 6.6.2 Configure identify[14943]: utility.c/ExpandFilenames/902/Configure
  Command line: identify {-debug} {all} {/tmp/seq-1.jp2}
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Policy identify[14943]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Path; rights=Read; pattern="/tmp/seq-1.jp2" ...
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Blob identify[14943]: blob.c/OpenBlob/2407/Blob
    read 3 magic header bytes
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/local/share/ImageMagick-6.6.2/config/magic.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/local/lib/ImageMagick-6.6.2/config/magic.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/local/share/doc/ImageMagick-6.6.2/magic.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/local/share/ImageMagick-6.6.2/magic.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/var/www/.magick/magic.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "magic.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: magic.c/LoadMagicList/678/Configure
  Loading magic configure file "/usr/local/share/ImageMagick-6.6.2/config/magic.xml" ...
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Policy identify[14943]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Coder; rights=Read; pattern="JP2" ...
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Policy identify[14943]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Path; rights=Read; pattern="/tmp/seq-1.jp2" ...
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Blob identify[14943]: blob.c/OpenBlob/2407/Blob
    read 3 magic header bytes
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Policy identify[14943]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Path; rights=Read; pattern="/tmp/seq-1.jp2" ...
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Blob identify[14943]: blob.c/OpenBlob/2407/Blob
    read 3 magic header bytes
error: cannot decode code stream
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Locale identify[14943]: locale.c/GetLocaleOptions/468/Locale
  Searching for locale file: "/usr/local/share/ImageMagick-6.6.2/config/locale.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Locale identify[14943]: locale.c/GetLocaleOptions/468/Locale
  Searching for locale file: "/usr/local/lib/ImageMagick-6.6.2/config/locale.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Locale identify[14943]: locale.c/GetLocaleOptions/468/Locale
  Searching for locale file: "/usr/local/share/doc/ImageMagick-6.6.2/locale.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Locale identify[14943]: locale.c/GetLocaleOptions/468/Locale
  Searching for locale file: "/usr/local/share/ImageMagick-6.6.2/locale.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Locale identify[14943]: locale.c/GetLocaleOptions/468/Locale
  Searching for locale file: "/var/www/.magick/locale.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Locale identify[14943]: locale.c/GetLocaleOptions/468/Locale
  Searching for locale file: "locale.xml"
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: locale.c/LoadLocaleList/769/Configure
  Loading locale configure file "/usr/local/lib/ImageMagick-6.6.2/config/locale.xml" ...
2010-08-31T09:38:58+02:00 0:00.010 0.010u 6.6.2 Configure identify[14943]: locale.c/LoadLocaleList/769/Configure
  Loading locale configure file "/usr/local/lib/ImageMagick-6.6.2/config/english.xml" ...
2010-08-31T09:38:58+02:00 0:00.010 0.020u 6.6.2 Exception identify[14943]: jp2.c/ReadJP2Image/400/Exception
  unable to decode image file `/tmp/seq-1.jp2'
2010-08-31T09:38:58+02:00 0:00.010 0.020u 6.6.2 Cache identify[14943]: cache.c/DestroyPixelCache/1601/Cache
  destroy 
identify: unable to decode image file `/tmp/seq-1.jp2' @ error/jp2.c/ReadJP2Image/400.
At the end i know he's loading the locale to show the error message, and he's removing everything from the cache. But before that he's doing something in policy.c IsRightsAuthorized, so i think i don't have enough rights, but i don't know on which file :s
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: JPEG-2000 problems

Post by Drarakel »

The debug messages look 'normal' to me.
When I execute the command on my system, there are three "read 3 magic header bytes" messages (like in your output), and after this third message, the picture apparently gets decoded (it takes 12 seconds on my system). But in your debug output, it doesn't seem to be successful, and you only have this "error: cannot decode code stream" there.
Don't know why. Maybe you could update to the latest IM version 6.6.3-9 and try again.
Can you also post the debug messages when you execute this command as root (you said that it works with that user).
fmw42 wrote:If I just change the suffix from jpf to jp2, then Mac Preview opens it just fine. IM display on unix does not. If I leave it as jpf, then the Max app GraphicConverter opens it fine.

With regard to the jp2 image, that also opens just fine in Mac Preview, but not in IM display.
Again - to be sure: Can the two images be decoded with ImageMagick (with identify) on your system? My installation can read 'seq-1' - but not 'Schutters_1'.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG-2000 problems

Post by fmw42 »

Again - to be sure: Can the two images be decoded with ImageMagick (with identify) on your system? My installation can read 'seq-1' - but not 'Schutters_1'.
IM 6.6.3.10 Q16 (HDRI):

identify -verbose

on either images does not work.
Post Reply