JPEG source files that really mess up subsequent effects

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
nurgus

JPEG source files that really mess up subsequent effects

Post by nurgus »

Hi all,

I've got Imagemagick integrated into my site and doing really well, but I've run into a major snag. I got a batch of jpeg images that need processing and Imagemagick's behaviour with them is very strange. The originals are huge hi-res monsters so I'm working with a crop called infile.jpg while I figure this out. I've spent days scratching my head and thoroughly searched forums and Google for an answer.

Now I'm officially giving up and asking for help!

Here's a basic example:

Code: Select all

convert infile.jpg -fill skyblue -draw "rectangle 20,10 80,80" outfile.jpg
infile.jpg:Imageoutfile.jpg:Image

Pretty obvious that's not right.. It works fine if I load infile.jpg in GIMP and save it again. But with this infile.jpg the draw colour is way out. I'm actually trying to stamp the images and do other effects, all of which are getting weird colours.

I have the same problem with versions 6.3.7 and 6.4.5, which are the versions with Ubuntu Hardy and Jaunty, and also the version on my webhost 6.5.2-9. The problem is obviously inherent to the jpeg files I have, but what can I do to fix it automatically?

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

Re: JPEG source files that really mess up subsequent effects

Post by fmw42 »

your infile is cmyk. change it to rgb

convert infile.jpg -colorspace rgb -fill skyblue -draw "rectangle 20,10 80,80" outfile.jpg


This works for me.
nurgus

Re: JPEG source files that really mess up subsequent effects

Post by nurgus »

Hey,

Wow, as easy as that!

I tried to examine the files with GIMP but it didn't seem to see anything odd with them. I guess it converts CMYK silently when it loads the image, which would explain why they worked after being loaded/saved.

This graphics n00b can now deploy these updated arguments, sit back and stop stressing. Hehe. 8)

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

Re: JPEG source files that really mess up subsequent effects

Post by fmw42 »

you can examine the image information in IM using identify -verbose imagefile
Post Reply