How to change the tone of an image.

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?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to change the tone of an image.

Post by fmw42 »

Post the results of this command

convert -version

It should list out all the delegate libraries you have installed. It should contain jpeg

If your IM version is too old to show the delegates, then run

convert -list configure

and post what it shows for the line starting with DELEGATES.

It would appear that you are missing the jpeg delegate library and perhaps many others depending upon how you did your install. If you installed from source rather than binary, then you need to install all the delegate libraries you need for jpg, png, tiff, ghostscript, etc

What platform are you on? linux, mac or windows?
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

I installed the latest version

Version: ImageMagick 6.8.5-7 2013-05-22 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: ps zlib
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

Even basic commands are also not working like "convert 123.jpg 123.png"

Error i am getting is,
convert: unable to open image `kartheek.jpg': No such file or directory @ error/blob.c/OpenBlob/2644.
convert: no decode delegate for this image format `kartheek.jpg' @ error/constitute.c/ReadImage/552.
convert: no images defined `kartheek.png' @ error/convert.c/ConvertImageCommand/3106.
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

When i run convert -version command the results are,

Version: ImageMagick 6.8.5-7 2013-05-22 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: ps zlib

When i run convert -list configure command the results are.

Path: /usr/local/lib/ImageMagick-6.8.5//config-Q16/configure.xml

Name Value
-------------------------------------------------------------------------------
CC gcc -std=gnu99 -std=gnu99
CFLAGS -fopenmp -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
CODER_PATH /usr/local/lib/ImageMagick-6.8.5/modules-Q16/coders
CONFIGURE ./configure
CONFIGURE_PATH /usr/local/etc/ImageMagick-6/
COPYRIGHT Copyright (C) 1999-2013 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include/ImageMagick-6
CXX g++
CXXFLAGS -g -O2 -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES ps zlib
DISTCHECK_CONFIG_FLAGS --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-gvc=no --with-rsvg=no --with-webp=no --with-wmf=no --with-perl=no
DOCUMENTATION_PATH /usr/local/share/doc/ImageMagick-6
EXEC-PREFIX /usr/local
EXECUTABLE_PATH /usr/local/bin
FEATURES DPC OpenMP
FILTER_PATH /usr/local/lib/ImageMagick-6.8.5/modules-Q16/filters
HOST x86_64-unknown-linux-gnu
INCLUDE_PATH /usr/local/include/ImageMagick-6
LDFLAGS -L/usr/local/lib
LIB_VERSION 0x685
LIB_VERSION_NUMBER 6,8,5,7
LIBRARY_PATH /usr/local/lib/ImageMagick-6.8.5
LIBS -lMagickCore -lz -lm -lgomp -lpthread
NAME ImageMagick
PCFLAGS -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
PREFIX /usr/local
QuantumDepth 16
RELEASE_DATE 2013-05-22
SHARE_PATH /usr/local/share/ImageMagick-6
SHAREARCH_PATH /usr/local/lib/ImageMagick-6.8.5/config-Q16
SVN_REVISION 12317
TARGET_CPU x86_64
TARGET_OS linux-gnu
TARGET_VENDOR unknown
VERSION 6.8.5
WEBSITE http://www.imagemagick.org

Path: [built-in]

Name Value
-------------------------------------------------------------------------------
FEATURES OpenMP
NAME ImageMagick
QuantumDepth 16

Yes, i installed from source not from binaries. Do you any documentation on how i can install all these missing libraries.

I am using Linux.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to change the tone of an image.

Post by fmw42 »

DELEGATES ps zlib
Those are the only delegate you have. So you need at least, jpg, png, tiff

These are mine. I would recommend at least the ones in blue


DELEGATES bzlib mpeg fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr lzma openexr png ps tiff x xml zlib

I am not sure why gs or ghostscript does not show in the list any longer. It used to. So I would also suggest you install ghostscript so that you can convert pdf and ps files.

I am on a Mac and get all my delegates from MacPorts. I do not know if there is anything equivalent for Linux. But you can find (probably older delegates) at http://www.imagemagick.org/download/delegates/. But I would search Google for each one to get the most recent ones.

Once you have the delegates successfully installed, then you will need to reinstall IM so that it can find them. Watch the installs carefully to be sure they install. Often they need other delegates to be installed before they can install.

You may be able to get most of the needed delegates installed if you install from an IM binary. So see http://www.imagemagick.org/script/binary-releases.php
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

Thanks for the quick reply.

When i run convert -version command the results are,

Version: ImageMagick 6.3.7 08/09/09 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC

When i run convert -list configure command the results are.

Path: /usr/lib/ImageMagick-6.3.7/config/configure.xml

Name Value
-------------------------------------------------------------------------------
CC gcc
CFLAGS -g -O2 -Wall -W -pthread
CONFIGURE ./configure --prefix=/usr --mandir=${prefix}/share/man --infodir=${prefix}/share/info --with-gs-font-dir=/usr/share/fonts/type1/gsfonts --with-magick-plus-plus --with-djvu --enable-shared --enable-lzw --without-dps --without-fpx --without-perl --with-perl-options=INSTALLDIRS=vendor --x-includes=/usr/include/X11 --x-libraries=/usr/lib/X11
COPYRIGHT Copyright (C) 1999-2008 ImageMagick Studio LLC
CPPFLAGS -I/usr/include
CXX g++
CXXFLAGS -g -O2 -Wall -W -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib djvu fontconfig freetype gvc jpeg jp2 lcms openexr png rsvg tiff wmf x11 xml zlib
DISTCHECK_CONFIG_FLAGS 'CFLAGS=-g -O2' 'CPPFLAGS=' 'LDFLAGS=' --disable-deprecate --with-quantum-depth=16 --with-dps=no --with-fpx=no --with-fontpath= --with-gs-font-dir=/usr/share/fonts/type1/gsfonts
EXEC-PREFIX /usr
HOST x86_64-unknown-linux-gnu
LDFLAGS -L/usr/lib -L/usr/lib/X11 -lfreetype -lz
LIB_VERSION 0x637
LIB_VERSION_NUMBER 6,3,7,9
LIBS -lMagick -llcms -ltiff -lfreetype -ljpeg -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lpthread
NAME ImageMagick
PCFLAGS
PREFIX /usr
QuantumDepth 16
RELEASE_DATE 08/09/09
VERSION 6.3.7
WEBSITE http://www.imagemagick.org

So, now i installed all the libraries which i used by "Image Magick"

I am trying execute the below command

"convert in.jpg -modulate 100,0,100 duotone.ppm -clut out.jpg"

In the above command

"in.jpg" is my original image.
"out.jpg" is the output image name which we will get after running the command.
"duotone.ppm" is the ppm file which you asked me to create.

The error which i am getting is,

convert: Improper image header `duotone.ppm'.
convert: missing an image filename `678.jpg'.

I don't know why i am getting this error. can you please help me.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to change the tone of an image.

Post by fmw42 »

IM 6.3.7 is rather old (almost 500 versions old). It is not clear why it does not work.
convert: Improper image header `duotone.ppm'.
convert: missing an image filename `678.jpg'.
It would appear to be an issue with your ppm image and its proper headers. Did you form the PPM image correctly according to the instructions by snibgo? Be sure that there are correct line endings in the text file for the ppm. You should be able to open it in any text editor or use cat duotone.ppm Does it have the headers formed as he shows in his list.

I am not sure where it is getting 678.jpg. I do not see that in your command. But if the duotone.ppm image is malformed, then I suppose anything that follows that message is suspect until you fix the ppm image.


I copied the code for the duotone image and pasted into an empty text file and saved as duotone.ppm. I downloaded your image in.jpg. I ran this command successfully

convert in.jpg duotone.ppm -clut show:

It shows a very similar image to your input but with a slight bluish cast.

If I add -modulate, to desaturate to grayscale first, then it is colorize blue.

convert in.jpg -modulate 100,0,100 duotone.ppm -clut show:

Anthony's Examples says:

Before IM v6.4.0-10 the "-modulate" operator actually did use HSB color space rather than HSL colorspace. This was changed because of a bug report by a user about the above situation.

So your results will look different from the nominal results on more current IM versions.


This was in my IM 6.8.5.7 Q16 Mac OSX system.

I see only two possibilities.

1) your ppm file is corrupt (open your file in a text editor and copy all of it and paste into your reply here, so we can verify it is not corrupt)

2) your IM version is too old

From Anthony's Examples, it says

The "-clut" operator was added to IM v6.3.5-8. So your version should be OK, but it is close to when it was added and there may have been bugs that were subsequently fixed.
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

Yes i did. let me copy and paste the ppm file here. Let me know if am doing anything wrong.

0,0,0
0,0,0
0,0,2
0,0,20
0,0,38
0,0,50
0,0,35
0,0,53
0,0,35
0,2,33
0,0,64
0,2,58
0,4,66
0,6,64
0,7,63
0,10,61
0,13,64
0,16,57
0,16,67
0,17,73
0,20,73
0,21,75
0,23,75
0,22,79
0,28,76
0,28,74
0,28,89
0,33,84
0,33,89
0,35,85
0,37,92
0,39,89
0,39,92
0,44,91
0,45,92
12,38,94
0,45,104
4,46,97
18,40,98
6,48,99
17,47,93
7,52,98
9,54,94
13,51,111
7,57,111
10,58,109
15,58,110
16,59,111
13,64,105
16,64,109
16,64,118
17,66,113
22,65,118
23,66,119
17,72,120
27,72,110
28,73,110
23,76,113
30,75,112
37,76,99
29,77,122
37,77,115
38,76,128
45,81,97
33,84,121
38,83,124
33,85,134
44,87,112
47,87,113
66,79,120
45,90,129
47,92,121
47,92,129
45,93,140
50,95,125
52,95,130
51,98,126
52,97,137
51,100,136
57,98,142
72,99,111
65,103,125
52,107,142
76,103,117
72,106,123
68,106,137
74,106,137
70,110,130
66,110,149
72,113,130
72,112,147
74,114,138
77,115,136
82,114,138
79,117,143
76,120,144
82,119,141
92,117,141
85,121,142
79,123,157
89,124,138
92,122,153
84,126,157
119,120,111
89,129,150
94,128,151
95,130,144
100,129,146
89,135,159
98,133,152
104,135,143
105,136,144
112,134,141
110,136,147
109,138,148
112,139,144
106,140,166
118,139,149
112,142,155
129,140,132
133,139,137
111,147,162
115,147,163
129,144,148
114,149,173
120,150,161
132,149,149
133,149,154
138,150,146
133,152,156
141,153,138
135,154,156
142,152,157
133,155,173
136,156,170
139,158,155
146,157,154
143,159,159
138,163,163
124,166,189
150,162,157
143,161,186
152,164,164
138,169,179
158,165,155
157,167,157
159,167,159
150,170,179
159,169,164
156,171,171
147,177,177
168,171,157
157,173,181
164,172,180
162,179,161
171,174,164
163,178,182
170,179,168
162,181,182
164,180,189
177,180,166
178,182,161
171,182,186
180,184,162
179,184,172
188,183,157
184,185,168
181,188,170
188,188,163
186,188,169
183,193,170
192,188,172
195,191,167
200,188,164
185,194,193
193,195,174
189,195,188
197,195,179
200,196,172
199,196,182
202,197,179
204,197,176
203,200,174
194,202,197
202,202,183
209,201,180
209,202,180
209,202,193
210,203,188
210,206,187
211,206,191
196,209,223
202,212,199
215,208,192
213,210,193
209,213,199
215,213,194
222,212,186
222,213,188
219,215,195
221,215,197
221,217,195
224,216,196
216,221,200
222,218,209
223,221,198
227,217,215
217,226,203
227,223,204
228,222,215
231,224,202
222,228,212
221,227,230
227,231,201
228,231,200
226,232,212
229,231,219
225,231,233
237,231,214
236,232,215
223,237,237
213,238,255
226,242,222
228,238,240
249,233,214
227,242,239
241,240,222
229,244,236
237,242,236
231,244,246
226,246,255
242,242,246
234,249,236
241,244,255
230,252,248
252,246,230
226,254,255
248,249,237
247,249,245
241,253,254
238,255,255
236,255,255
243,255,255
239,255,255
239,255,255
240,255,255
240,255,255
241,255,255
255,255,255
247,255,255
255,255,255
252,255,255
255,255,255
255,255,255
255,255,255
255,255,255

Actually i am using "convert in.jpg -modulate 100,0,100 duotone.ppm -clut out.jpg"
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

Can you send me the duotone image which you got when you tested.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to change the tone of an image.

Post by fmw42 »

You are missing the headers that tell the file it is PPM. see viewtopic.php?f=1&t=23466#p98843

Add these three lines at the top of your file

P3
255 1
255

If you still have trouble, let me know your email address and I can send you my duotone.ppm file
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

It fixed my problem thanks a lot.

But i have a one more question for you.

Below are two image url's one is the Original Duotone image (1st url) from our site and other one is which i converted by image magicx (2nd url)

Image
Image

If you observer both 1st image (1st image) looks little dull than 2nd one (Converted one 2nd image). What should i do to make converted one look same like original one.

right now i use command convert kar.jpg -modulate 100,0,100 duotone.ppm -clut sow.jpg to resize.

Do i need to change any modulate numbers?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to change the tone of an image.

Post by fmw42 »

How did you create the first one? It is likely the difference in the colorspace used by -modulate. As I mentioned, in your version the only colorspace you could use was HSB. But in more current versions of IM, it has been changed to HSL (actually you have the option to change it to HSL or HSB or possibly HCL).

I am not sure how to adjust it, but you could try changing the modulate hue value (the third number from 100) so that your image is a bit more blue. See http://www.imagemagick.org/Usage/color_ ... dulate_hue.

Also depending upon the input image coloration, you may be able to keep more of the input color by increasing the second modulate number (saturation up a bit from 0).

If you can provide your input image, perhaps we can test other techniques to try to match better using HSB colorspace.

You would have more flexibility if you upgrade your version of IM.
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

Here is the input image.

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

Re: How to change the tone of an image.

Post by fmw42 »

This is what I get by using in IM 6.8.5.7 Q16


convert khr.jpg -define modulate:colorspace=HSL -modulate 100,0,100 duotone.ppm -clut khr_hsl_duotone.jpg


which uses HSL rather than HSB colorspace in -modulate.


Image

To be able to do that you need to be using IM v6.5.3-7 or higher for HSL using the define. So your cannot use the -define with your version. But if you are using IM 6.4.0-10 or higher HSL will be the default.
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: How to change the tone of an image.

Post by helloworld »

How can i upgrade to the latest one? Do i need uninstall the old one and need to install the new one with all the delegates?

Do we have different ppm headers for different tones? just like for previous Duotone you gave ppm header has
P3
255 1
255
Post Reply