Page 1 of 1

montage ... -transparent #COLOR failes to make color transpa

Posted: 2007-03-11T05:26:19-07:00
by hellpimp
I had an old command from about a year ago to rotate two images, montage them together, and make the background color transparent, which was done with the following:

Code: Select all

montage -geometry +0+0 ( -background MistyRose -resize 200x200 -rotate -30 <file1> ) -geometry +0+0 ( -background MistyRose -resize 200x200 -rotate 30 <file2> ) -transparent MistyRose -quality 10 <output>
This used to work (on which version of ImageMagick I do not remember). The -quality 10 call was used when outputting the file as a .png.

When I moved to a new PC using version 6.3.2 Q16 (and now 6.3.3 Q16), and tried to re-run the batch file, the command no longer resulted in an image with a transparent background. I tried everything I could think of (specifying an Alpha value in the background color, moving the location of -transparent, etc...), but it would leave the background color intact. I tried using the .miff format in case something was getting lost, but nothing changed.

The solution was to simply mogrify the image:

Code: Select all

mogrify -transparent MistyRose <output>"
My question, finally, is has anyone else noticed an issue with the -transparent tag when using montage? Why would -transparent work when mogrifying the resulting image, but not while creating the image? Am I doing something wrong in my montage call?

Re: montage ... -transparent #COLOR failes to make color transpa

Posted: 2007-03-11T09:22:14-07:00
by el_supremo
Try putting both <file> before -resize.
IM V6 changed the way commands are specified and that looks like it would have worked with V5 syntax.
Pete

Re: montage ... -transparent #COLOR failes to make color transpa

Posted: 2007-03-11T22:21:42-07:00
by anthony
You have it right el_supremo read the image BEFORE modifing the image.

See IM Examples Basics for command line ordering.
And more specifically Im Examples Montage for how IM processes montage.
http://www.imagemagick.org/Usage/monatge/

The major example on settings would probably be a big help to you..
http://www.imagemagick.org/Usage/monatge/#reuse

Re: montage ... -transparent #COLOR failes to make color transpa

Posted: 2007-03-12T21:32:13-07:00
by hellpimp
I don't think moving the files will accomplish what I want. What I am trying to do is read in two normally-sized pictures. Resize each one to 200x200, then rotate the first -30 degrees and the second by +30. When I montage the two together, they come together in a sort of V-shape. I need the background transparent so I can compose the result onto another image.

I changed my command to various orders such as:

Code: Select all

montage -background MistyRose <image1> -rotate -30 <image2> -resize 200x200 -rotate 30 -transparent MistyRose -geometry +0+0 <output>
This results in one image being rotated -30 then +30, so it ends back up where it was, only the first image is now smaller, because it was rotated (which gave it a greater width-height), then shrunk, then rotated back. Setting the first rotate to -60 doesn't help, because the image is still reduced in size more than the second image.

Code: Select all

montage -background MistyRose <image1> <image2> -resize 200x200 -rotate 30 -transparent MistyRose -geometry +0+0 <output>
The command above came closest to what I want, but then both images are rotated at +30, and the image is STILL not transparent, which was my only problem to begin with. The old command worked fine under V6 with respect to resizing and rotating (though maybe it did extra processing or used extra resources, of which I have plenty), but the result was not transparent.

So, is there an issue with including -transparent (even if I make it the very last command to montage)?

And now I have a new question, how do I separate -rotate calls in the same command without creating intermediate images (using parens) as I had been doing before?

Re: montage ... -transparent #COLOR failes to make color transpa

Posted: 2007-03-12T23:29:55-07:00
by anthony
The problem is the background comming from the -rotate. You want this transparent!

Replace MistyRose with None...

Code: Select all

montage -background None \
       \( logo:  -resize 200x200 -rotate -30 \) \
       \( rose: -resize 200x200 -rotate 30 \) \
       \
      -background None  geometry +0+0   output.png
the second -background is not strictly needed, but present to so that it is the montage setting you want, where the first is the -rotate setting that was giving you problems.

You can also replace the second -background with -texture to underlay a image or tile as the background for the montage.

See IM examples, Monatge for more info.
And read the IM examples, Distorting Images Rotate!
http://www.imagemagick.org/Usage/distorts/#rotate
which is the key to your problem.

Re: montage ... -transparent #COLOR failes to make color transpa

Posted: 2007-03-14T20:23:24-07:00
by hellpimp
Thank you much, that works.

Whatever older version of IM I was using before did not allow me to specify None or an otherwise transparent background (i.e. it didn't work), so I had to create a colored background and then make it transparent.

Re: montage ... -transparent #COLOR failes to make color transpa

Posted: 2007-03-18T05:28:13-07:00
by anthony
That was a long time ago, in the early days of IM v6 IM v5 just did not do it ever.