Page 1 of 1

Compose image yields odd results

Posted: 2007-03-22T23:16:55-07:00
by losttime
Very new to IM, so I'm sorry if this has an obvious answer.

I'm on a shared server with IM version 6.2.6. I'm trying to compose two images together using the command line.

This command (composite image.jpg shirt.jpg result.jpg) seems to reproduce image.jpg and shirt.jpg and call them result-0.jpg and result-1.jpg.

I tried using the convert command. This command (convert shirt.jpg image.jpg -composite result.jpg) produces result.jpg that looks like shirt.jpg with a black square the size of image.jpg on top of it. Something like this ...
Image

I really have no idea what to try next. Any suggestions for me?

Re: Compose image yields odd results

Posted: 2007-03-23T06:03:36-07:00
by anthony
See IM Examples. It has lots to try next.
In your case look in the Alpha Composition section.
http://www.imagemagick.org/Usage/compose/

Re: Compose image yields odd results

Posted: 2007-03-23T08:17:01-07:00
by losttime
Thank you for the suggestion, but I have read through that documentation many times and nothing I have tried has been any better.

I'm trying to keep the commands simple initially to eliminate variables. Then when I get it working I'll add in things like size and positioning. As it is, it seems to me like either of those simple commands ('composite image.jpg shirt.jpg result.jpg' OR 'composite image.jpg shirt.jpg result.jpg') should take these images:
ImageImage
and turn them into something more like this:
Image

Am I wrong in that assumption?

Re: Compose image yields odd results

Posted: 2007-03-23T14:47:21-07:00
by Bonzo
How about adding some links to your images ?

I would use convert shirt.jpg image.jpg -composite result.jpg

Re: Compose image yields odd results

Posted: 2007-03-23T14:59:28-07:00
by el_supremo
After some trial and error, I found that with black and white images this convert command appears to do what you want:

Code: Select all

convert shirt.jpg image.jpg -compose multiply -composite result.jpg
[EDIT]: If you want the image to look like your example use SrcOver instead of multiply.

Pete

Re: Compose image yields odd results

Posted: 2007-03-23T19:14:06-07:00
by anthony
losttime your command from what I can see should work. All I can think of is something is wrong with your input images.

Bonzo your example is exactly the same as the composite form, and should yeald the same result, bad if imputs are bad. The advantage of convert is that you can do other things before and after the composition.

and finally..
el_supremo Your command will do the job and will probably do what losttime really wants, (it adds black, never white to an image), but that is not dealing with the original problem.

losttime please post some links to the problem images so we can play with them and verify your problem and figure out the cause or the fix.

Lastly, applogies to everyone if I seem a little testy.

Re: Compose image yields odd results

Posted: 2007-03-23T23:01:54-07:00
by losttime
Thank you for your input everyone.

Yes, what I'd really like to accomplish is what would be acheived by '-compose multiply', but since that wasn't working for me I thought I'd just try these simple commands for now.

Hmm ... in gathering the image links for you I discovered that my base image ('shirt.jpg') has some sort of error that prevents it from being displayed in the web browser. I've been noticing lately that Photoshop images saved as jpgs seem to have errors unless you specifically use the "Save for Web" feature. I won't be able to get an error-free file until Monday, but I imagine that could fix my problem. Until then, here are the image links anyway:

The shirt: http://www.graphichabit.com/redesign/im ... /tee_l.jpg
The design: http://www.graphichabit.com/redesign/im ... dina01.jpg
The results: http://www.graphichabit.com/redesign/im ... l/test.jpg (when using convert -compose);
http://www.graphichabit.com/redesign/im ... test-0.jpg (when using compose [A]);
http://www.graphichabit.com/redesign/im ... test-1.jpg (when using compose ).

Re: Compose image yields odd results

Posted: 2007-03-24T02:27:15-07:00
by Bonzo
As you say there is an error on the shirt jpg as when I download and try opening it I get the following errors:
Premature end of JPEG file Exif data will be ignored.

Corrupt JPEG data: 167854 exteneous bytes before marker 0xd9 Exif data will be ignored.

JPEG downstream contains no image Exif data will be ignored.


P.S. Searching google for " photoshop Corrupt JPEG data: extraneous bytes before marker " I found other people have had this problem and some old IM posts about it. Seems IM could cope with it as somebody could open similar corrupted images in 3.9.2

Re: Compose image yields odd results

Posted: 2007-03-25T18:13:31-07:00
by anthony
More than likely that former open success was removed during various JPEG library upgrades.

Re: Compose image yields odd results

Posted: 2007-03-26T17:11:34-07:00
by losttime
Now that I have an error free file on the server, the "convert" command works wonderfully. The "composite" command still yields two, non-composited files. Any idea why that would be happening?

Re: Compose image yields odd results

Posted: 2007-03-26T19:14:10-07:00
by anthony
That is strange as while convert can generate two images, composite can NOT.