Converting Pyramidal TIFF to JPEG2000

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?".
Post Reply
syamashi
Posts: 12
Joined: 2012-10-05T11:09:07-07:00
Authentication code: 67789

Converting Pyramidal TIFF to JPEG2000

Post by syamashi »

Hello,

I'd like to convert Pyramidal TIFF to JPEG2000. However, the generated files are separated in to seven different files which I believe they are associated with the resolution levels. The following command worked for flat TIFFs to generate a single file:

% convert source_image -define numrlvls=7 -define jp2:tilewidth=1024 -define jp2:tileheight=1024 -define jp2:rate=0.02348 -define jp2:prg=rpcl -define jp2:mode=int -define jp2:prcwidth=1024 -define jp2:prcheight=1024 -define jp2:cblkwidth=64 -define jp2:cblkheight=64 -define jp2:sop output_image

Could anyone shed light on how to tweak the parameters so that I can prevent the output to generate a single consolidated file?

Thanks for your help,
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Converting Pyramidal TIFF to JPEG2000

Post by anthony »

Code: Select all

convert  image.tiff  -delete 1--1 ....
The delete removes the second image (index 1) to the last image (index -1).
See IM Examples, Basics, Delete
http://www.imagemagick.org/Usage/basics/#delete

or
convert image.tiff"[0]" ....

See IM Examples, File Handling, Read modifiers
http://www.imagemagick.org/Usage/files/#read_mods
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
syamashi
Posts: 12
Joined: 2012-10-05T11:09:07-07:00
Authentication code: 67789

Re: Converting Pyramidal TIFF to JPEG2000

Post by syamashi »

Hi anthony,

Thanks for you reply. That should work on what I intend to do. I also have two more question regarding this conversion and I hope you don't mind answering.

I'm attempting to convert a TIFF file which is 14000x11000 in size and the lowest resolution level of the JPEG2000 from previous convert command gives me "229x172" in size. However, I intend to get "106x79" for the lowest resolution level. I've tried tweaking the parameters but none of them seem to get as I expect. For example, I've tried various "numrlvls" from 6~9. Is there anyway I can tweak the parameters to get much smaller size of lowest resolution level? The other question is, does ImageMagick has a command to get basic information of the JPEG2000 file? For example, I'd like to extract how many resolution levels are there and what sizes for each level.

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

Re: Converting Pyramidal TIFF to JPEG2000

Post by fmw42 »

Perhaps there is some automatic padding that you will not be able to remove, or there is some virtual-canvas created that is larger than you expect. For the latter, try adding +repage before the output.
syamashi
Posts: 12
Joined: 2012-10-05T11:09:07-07:00
Authentication code: 67789

Re: Converting Pyramidal TIFF to JPEG2000

Post by syamashi »

Hi,

I tried with "+repage" option but that didn't help. The lowest resolution level comes out in "229x172". Here is the command I'm running:

Code: Select all

convert input.tif -define jp2:numrlvls=7 -define jp2:tilewidth=1024 -define jp2:tileheight=1024 -define jp2:rate=0.02348 -define jp2:prg=rpcl -define jp2:mode=int -define jp2:prcwidth=1024 -define jp2:prcheight=1024 -define jp2:cblkwidth=64 -define jp2:cblkheight=64 -define jp2:sop +repage output.jp2
Is there a way to know the dimensions of each level?

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

Re: Converting Pyramidal TIFF to JPEG2000

Post by fmw42 »

idenify -verbose yourimage

should tell you everything about each level

If you just want the wxh you can do

convert yourimage -format "%w x %h" info:

and it should list that information for each level
syamashi
Posts: 12
Joined: 2012-10-05T11:09:07-07:00
Authentication code: 67789

Re: Converting Pyramidal TIFF to JPEG2000

Post by syamashi »

Interestingly, I was not able to list the dimensions with one consolidated JPEG2000 file as opposed to what listed with Pyramidal TIFF file. However, I managed to print the dimensions of individually generated files and they appeared to be the same dimensions.

thanks for your help,
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting Pyramidal TIFF to JPEG2000

Post by fmw42 »

syamashi wrote:Interestingly, I was not able to list the dimensions with one consolidated JPEG2000 file as opposed to what listed with Pyramidal TIFF file. However, I managed to print the dimensions of individually generated files and they appeared to be the same dimensions.

thanks for your help,

Perhaps IM does not support Pyramid structures in JP2000. It may be a limitation of the Jasper delegate library. Check the docs on Jasper and see if it does support it and report back.
syamashi
Posts: 12
Joined: 2012-10-05T11:09:07-07:00
Authentication code: 67789

Re: Converting Pyramidal TIFF to JPEG2000

Post by syamashi »

Check the docs on Jasper and see if it does support it and report back.
Sorry, I couldn't find this.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting Pyramidal TIFF to JPEG2000

Post by fmw42 »

Post Reply