Search code examples
graphicsmagick

GraphicsMagick: issues resizing the output after composition


I’m hoping someone can point me in the right direction.

I’ve been trying to use GraphicsMagick to composite three images with a small tweak to one of the colours as well.

The first two images are the same size and are positioned at 0, 0. The third image is smaller, a “design” image and I’ve offset this using –page 320,300.

Everything seems fine up to mosaic.

When I do the resize I would have hoped after the mosaic for the whole image to be resized as one but instead it apples the resize to each of the layers, leaving the third image resized incorrectly.

Is there a way I can solve the resize to work here?

Here is the command I am using:

gm convert -background transparent background.png -compose multiply -fill "#FFCCAA" \
    -opaque "#FFFFFF" foreground.png -page +320+300 design.png -mosaic \
    -resize 300x300 result.png

Added example of problem: https://i.sstatic.net/gJZlE.jpg


Solution

  • Not sure if this helps, but it may be what you seek. Start with a.png and b.png which are both 300x300 and c.png which is 100x100.

    enter image description here

    enter image description here

    enter image description here

    Now composite b onto a and resize c and composite and resize the result:

    gm convert a.png -draw "image multiply 0,0 0,0 b.png" -draw "image multiply 100,150 30,30 c.png" -resize 800x300! result.png
    

    enter image description here