sharp-cli icon indicating copy to clipboard operation
sharp-cli copied to clipboard

Support for composite multiple images

Open vntrungld opened this issue 2 years ago • 3 comments

How to composite multiple images by a single command? I'm making a PHP SDK for Sharp using this project so maybe we need a solution for composite multiple images like Imagick.

vntrungld avatar Sep 12 '22 10:09 vntrungld

Can you show me what you tried? Although I have not tried this, you should be able to compose multiple images using something like sharp composite <image1> -- composite <image2>.

vseventer avatar Sep 16 '22 02:09 vseventer

Hi @vseventer, sorry for the late response The command I've tried is:

sharp -i background-min.png -o result-min.png -f png -- composite face-min.png --gravity southeast -- composite flower-min.png --gravity southeast

I tried to put face and flower on the background but the result only have flower and background. Look like the command only takes the latest composite image background-min face-min flower-min result-min

vntrungld avatar Sep 20 '22 03:09 vntrungld

Thanks for providing this - while Sharp allows compositing multiple images, the CLI is not passing the images in the right format.

Since this likely affects other operations too, I got to dig a bit deeper and figure out a pattern that works for all affected areas.

vseventer avatar Sep 20 '22 12:09 vseventer

Fixed in #75 - hoping to complete that PR soon and release a new major version.

In your case, usage will be:

sharp -i background-min.png -o result-min.png -f png composite face-min.png flower-min.png --gravity southeast

vseventer avatar Dec 09 '22 01:12 vseventer

Fixed in v4.0.0, now available.

vseventer avatar Dec 10 '22 00:12 vseventer