Hi: Gurus, we have some scanned Tiff files with JPEG 7 compression. All these files are color and scanned as 24 bit per pixel. I wonder is it possible to change the depth of bit per pixel from 24 to 8 bit? If yes does some one know how to do it via ImageMagick?
Regards,
Rashid.
changing the bit depth of Tiff file from 24 to 8 bit
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: changing the bit depth of Tiff file from 24 to 8 bit
This should do it assuming IM supports tiff files with JPEG 7 compression.
convert image.tiff -depth 8 -type palette newimage.tiff
Can you post a link to your input image so we can test?
As a simple test, I created a JPG compressed tiff
convert rose: -compress jpeg rose_cjpg.tiff
Then convert to 8-bit palette
convert rose_cjpg.tiff -depth 8 -type palette rose_cjpg_palette.tiff
But it is still type Truecolor and not palette.
So I think you need to remove the compression first. So I tried
convert rose_cjpg.tiff -compress none -depth 8 -type palette rose_cjpg_cnone_palette.jpg
or reversing the order of -depth and -type
convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.jpg
But that is still type Truecolor.
So I converted to MIFF and then TIFF
convert rose_cjpg.tiff -compress none MIFF:- | convert - -depth 8 -type palette rose_cjpg_cnone_palette2.tiff
Which is type palette but 16-bits. It seems to ignore the -depth.
Using IM 6.8.6.7 Q16 Mac OSX
EDIT: If the -depth and -type are reversed it does work when using MIFF intermediate, but does not work directly as shown above.
convert rose_cjpg.tiff -compress none MIFF:- | convert - -type palette -depth 8 rose_cjpg_cnone_palette3.tiff
I am not sure why this should be order dependent. Seems like a possible bug in that regard and with respect to needing to use MIFF as an intermediate.
convert image.tiff -depth 8 -type palette newimage.tiff
Can you post a link to your input image so we can test?
As a simple test, I created a JPG compressed tiff
convert rose: -compress jpeg rose_cjpg.tiff
Code: Select all
Image: rose_cjpg.tiff
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 70x46+0+0
Units: PixelsPerInch
Type: TrueColor
Base type: TrueColor
Endianess: MSB
Colorspace: sRGB
Depth: 8-bit
Then convert to 8-bit palette
convert rose_cjpg.tiff -depth 8 -type palette rose_cjpg_palette.tiff
Code: Select all
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 70x46+0+0
Units: PixelsPerInch
Type: TrueColor
Base type: TrueColor
Endianess: MSB
Colorspace: sRGB
Depth: 8-bit
So I think you need to remove the compression first. So I tried
convert rose_cjpg.tiff -compress none -depth 8 -type palette rose_cjpg_cnone_palette.jpg
or reversing the order of -depth and -type
convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.jpg
Code: Select all
Image: rose_cjpg_cnone_palette.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
So I converted to MIFF and then TIFF
convert rose_cjpg.tiff -compress none MIFF:- | convert - -depth 8 -type palette rose_cjpg_cnone_palette2.tiff
Code: Select all
Image: rose_cjpg_cnone_palette2.tiff
Format: TIFF (Tagged Image File Format)
Class: PseudoClass
Geometry: 70x46+0+0
Units: PixelsPerInch
Type: Palette
Base type: Palette
Endianess: MSB
Colorspace: sRGB
Depth: 16-bit
Using IM 6.8.6.7 Q16 Mac OSX
EDIT: If the -depth and -type are reversed it does work when using MIFF intermediate, but does not work directly as shown above.
convert rose_cjpg.tiff -compress none MIFF:- | convert - -type palette -depth 8 rose_cjpg_cnone_palette3.tiff
Code: Select all
Image: rose_cjpg_cnone_palette3.tiff
Format: TIFF (Tagged Image File Format)
Class: PseudoClass
Geometry: 70x46+0+0
Units: PixelsPerInch
Type: Palette
Base type: Palette
Endianess: MSB
Colorspace: sRGB
Depth: 8-bit
I am not sure why this should be order dependent. Seems like a possible bug in that regard and with respect to needing to use MIFF as an intermediate.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: changing the bit depth of Tiff file from 24 to 8 bit
Topic continued in Bugs forum. See viewtopic.php?f=3&t=23845
Note I made a mistake above when testing
convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.jpg
I accidentally used jpg for the output.
It works if the output is tiff
convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.tiff
Note I made a mistake above when testing
convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.jpg
I accidentally used jpg for the output.
It works if the output is tiff
convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.tiff