[SOLVED] Image.tif change RGB to idexed color

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
absalom
Posts: 3
Joined: 2017-12-21T05:42:56-07:00
Authentication code: 1152

[SOLVED] Image.tif change RGB to idexed color

Post by absalom » 2017-12-25T23:29:44-07:00

Hello,
I have scanned a children's book with text and colored drawings on the same page.
I have processed the pages with ScanTailor (combined mode), the result is black-white text and the drawings keep their color, it is very good.

But the pages have a big size (5 to 10mb, pages.tif).
Then with GIMP change color RGB to indexed (menu, image, mode, indexed color). This reduces its size to 1 or 2 mb.

my question.
Can I do this with imagemagick? change from RGB to indexed color and thus decrease size.
and can I do it for many pages at once? :D

Thanks.




--------------------------
Linux openSUSE Tumbleweed KDE.
ImageMagick 7.0.7.11-2.1 (command line)
Last edited by absalom on 2017-12-30T00:01:22-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 22481
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Image.tif change RGB to idexed color

Post by fmw42 » 2017-12-25T23:59:14-07:00

Code: Select all

convert image.tif -depth 8 -type palette newimag.tif
and if you want compress with lzw compression.

Code: Select all

convert image.tif -depth 8 -type palette -compress lzw newimag.tif

absalom
Posts: 3
Joined: 2017-12-21T05:42:56-07:00
Authentication code: 1152

Re: Image.tif change RGB to idexed color

Post by absalom » 2017-12-26T09:09:39-07:00

@fmw42

Yes, it works very well. (But it does not reduce the size as much as gimp. :? )

¿How can I do it with all the images in a folder (100 files) ?

Thanks.

User avatar
fmw42
Posts: 22481
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Image.tif change RGB to idexed color

Post by fmw42 » 2017-12-26T11:35:14-07:00

Use mogrify rather than convert.

Lets say your images are in directory, test1. Create a new directory, test2, to hold the results.

change directories to test1

Code: Select all

mogrify -format tif -path path2/test2 -depth 8 -type palette -compress lzw *.tif
See http://www.imagemagick.org/Usage/basics/#mogrify

absalom
Posts: 3
Joined: 2017-12-21T05:42:56-07:00
Authentication code: 1152

Re: Image.tif change RGB to idexed color

Post by absalom » 2017-12-30T00:00:09-07:00

the script

Code: Select all

"path2/test2"
does not work.

I used

Code: Select all

mogrify -format tif -path test2 -depth 8 -type palette -compress lzw *.tif
and it worked very well.

thanks for your help.
greetings from Chile
:D :D

User avatar
fmw42
Posts: 22481
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: [SOLVED] Image.tif change RGB to idexed color

Post by fmw42 » 2017-12-30T11:11:39-07:00

path2/ was just placeholder for your actual path to your new directory

Post Reply