I have a large set of .jp2 files with incorrect metadata and I need to know the proper way to convert them to good/valid .jpg files
'identify -verbose' says:
Format: JP2 (JPEG-2000 File Format Syntax)
Class: DirectClass
Geometry: 2912x4368+0+0
Resolution: 72x72
Print size: 40.4444x60.6667
Actually, the resolution is 360x360 and the print size is approx 8 x 12 inches
Q: What is the proper way to fix the metadata in these .jp2 files so that the geometry stays the same but the resoluion is changed to 360x360 so that the print size drops to the correct values?
Now, in reality I want to convert them to 150x150 dpi quality 70 .jpg images. I am having trouble with convert because the resolution is wrong. If the input .jp2 files were correct I would want to say:
convert foo.jp2 -resample 150x150 -quality 70 foo.jpg
However, given that the resolution & dimensions of the input files is messed up, I don't really know how to deal with it.
Any assistance appreciated.
Thanks,
Michael
incorrect metadata in .jp2 files
-
- Posts: 5
- Joined: 2010-07-30T14:54:36-07:00
- Authentication code: 8675308
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: incorrect metadata in .jp2 files
Seems that there may be a more serious issue.
convert logo: -density 300 -units pixelsperinch JP2:logo_jpg2000.jp2
identify -verbose logo_jpg2000.jp2
Image: logo_jpg2000.jp2
Format: JP2 (JPEG-2000 File Format Syntax)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
I know little about JP2 format, so perhaps it does not support density?
Someone who knows more about JP2 and density will need to answer this.
Furthermore, if I do:
convert logo_jpg2000.jp2 -density 300 -units pixelsperinch logo_jpg2000.jpg
The resulting jpg gets the wrong density
identify -verbose logo_jpg2000.jpg
Image: logo_jpg2000.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: PixelsPerInch
And even this gets the wrong density:
convert logo: -density 300 -units pixelsperinch logo.jpg
identify -verbose logo.jpg
Image: logo.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: PixelsPerInch
Looks like -density is not working in IM 6.6.3.1 Q16 Mac OSX Tiger.
Can someone else verify or tell me I have a misunderstanding? Is density not stored in JPG or JP2 files?
convert logo: -density 300 -units pixelsperinch JP2:logo_jpg2000.jp2
identify -verbose logo_jpg2000.jp2
Image: logo_jpg2000.jp2
Format: JP2 (JPEG-2000 File Format Syntax)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
I know little about JP2 format, so perhaps it does not support density?
Someone who knows more about JP2 and density will need to answer this.
Furthermore, if I do:
convert logo_jpg2000.jp2 -density 300 -units pixelsperinch logo_jpg2000.jpg
The resulting jpg gets the wrong density
identify -verbose logo_jpg2000.jpg
Image: logo_jpg2000.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: PixelsPerInch
And even this gets the wrong density:
convert logo: -density 300 -units pixelsperinch logo.jpg
identify -verbose logo.jpg
Image: logo.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: PixelsPerInch
Looks like -density is not working in IM 6.6.3.1 Q16 Mac OSX Tiger.
Can someone else verify or tell me I have a misunderstanding? Is density not stored in JPG or JP2 files?
Re: incorrect metadata in .jp2 files
Yup, the same here. "-density" is broken.
I think I will create a bug report (as I already have another small issue with "-density" and "-units").
@michaelufl:
What version of ImageMagick are you using?
You can either wait till this bug gets fixed - or just use version 6.6.3-0 (or an older one). But "-resample" is the wrong option - "-density" is the right one (as in fmw42's examles). To be on the safe side, you should change the density like that (example with 150dpi):
convert -units PixelsPerInch <input> -density 150 <output>
If you want to change only metadata, you might consider using a tool like ExifTool - which is specialized in doing such things.
Besides, are you sure that your JP2 images have wrong metadata? I could be wrong - but it seems that ImageMagick can't use the metadata in JP2 (apart from the color profile). So, ImageMagick doesn't display the 'real' density (that could be stored in additional profiles) in JP2.
I think I will create a bug report (as I already have another small issue with "-density" and "-units").
@michaelufl:
What version of ImageMagick are you using?
You can either wait till this bug gets fixed - or just use version 6.6.3-0 (or an older one). But "-resample" is the wrong option - "-density" is the right one (as in fmw42's examles). To be on the safe side, you should change the density like that (example with 150dpi):
convert -units PixelsPerInch <input> -density 150 <output>
If you want to change only metadata, you might consider using a tool like ExifTool - which is specialized in doing such things.
Besides, are you sure that your JP2 images have wrong metadata? I could be wrong - but it seems that ImageMagick can't use the metadata in JP2 (apart from the color profile). So, ImageMagick doesn't display the 'real' density (that could be stored in additional profiles) in JP2.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: incorrect metadata in .jp2 files
Thanks for verifying and for submitting the bug report.Drarakel wrote:Yup, the same here. "-density" is broken.
I think I will create a bug report (as I already have another small issue with "-density" and "-units").
Fred
P.S. Just to be sure, I even checked some of these files with exiftool and it shows resolution at 72 rather than 300 as I specified it.
Re: incorrect metadata in .jp2 files
Did anything come of the bug report? I m also having difficulties having IM encode the dpi within a jp2.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: incorrect metadata in .jp2 files
See viewtopic.php?f=1&t=10971
It might be the same issue, that the jasper delegate does not support setting that value. But I will defer to the IM developers as I am not an expert on JP2.
It might be the same issue, that the jasper delegate does not support setting that value. But I will defer to the IM developers as I am not an expert on JP2.