sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Is it possible to create a non-rectangular shape from a rectangular image? Or join rectangular images together at a slant?

Open davitykale opened this issue 3 years ago • 4 comments

Question about an existing feature

What are you trying to achieve?

I am trying to create a larger, rectangular image that is a composite of 5 images. The images appear as slanted parallelograms when they are joined together.

My initial thinking was to "extract" a parallelogram for each of the 5 and then join the 5 together. But I am not sure the best way to achieve this and if it's even possible with sharp.

When you searched for similar issues, what did you find that might be related?

I did not find anything that seemed related.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question

Not sure what to put here.

davitykale avatar Aug 09 '22 16:08 davitykale

PNG image

This is essentially the effect that I am trying to achieve, but starting with typical rectangular images for each individual

davitykale avatar Aug 11 '22 21:08 davitykale

Hi, have you considered the use of SVG as a way of building such an image?

lovell avatar Aug 13 '22 23:08 lovell

Would your recommendation to be turn each individual photo into an SVG and then combine them? Or am I missing something 

On August 13, 2022, Cosma Damiano Trimboli @.***> wrote:

Hi, have you considered the use of SVG as a way of building such an image?

— Reply to this email directly, view it on GitHub https://github.com/lovell/sharp/issues/3329#issuecomment-1214246961, or unsubscribe <https://github.com/notifications/unsubscribe- auth/AUEC7J56R42DYTBPSQZ4RADVZAWZVANCNFSM56BLSGJA>. You are receiving this because you authored the thread.Message ID: @.***>

davitykale avatar Aug 14 '22 03:08 davitykale

You should be able to do this in a single SVG file. Perhaps try embedding base64-encoded images and apply a clipPath containing the parallelogram shape to them.

<image xlink:href="data:image/jpeg;base64,..." clip-path="..." />

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/clipPath

lovell avatar Aug 14 '22 13:08 lovell

I hope this information helped. Please feel free to re-open with more details if further assistance is required.

lovell avatar Dec 07 '22 09:12 lovell