vseventer / sharp-cli

CLI for sharp.
MIT License
189 stars 20 forks source link

Support for composite multiple images #73

Closed vntrungld closed 1 year ago

vntrungld commented 2 years ago

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.

vseventer commented 2 years ago

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>.

vntrungld commented 2 years ago

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

vseventer commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

Fixed in v4.0.0, now available.