Skip to content

[question] concating images #864

Closed
Closed

Description

@Bnaya

Lets say i have 4 100X100 images
And i want to concat them for a 100X400 image.

I've tired to do this:

    const fullScreenshotSharp = sharp(Buffer.from([]), <any>{
        create: {
            width: 100,
            height: 400,
            channels: 4,
            background: "rgba(0, 0, 0, 0)",
        }
    }); 

And then

        fullScreenshotSharp.overlayWith(screenshotFragmentBuffer, {
            top: i,
            left: 0,
        });

For each image with the appropriate i
But in each tick the rest of the image is covered with the background: "rgba(0, 0, 0, 0)"
deleting my previous work

Thanks!

EDIT
What i did for now is to recreate sharp object on each iteration from the output of the last one.

        fullScreenshotSharp = await sharp(await fullScreenshotSharp.toBuffer());

I hope there's a better way

Activity

  1. lovell commented on Jul 4, 2017

    @lovell
    Owner

    #728 is tracking a possible future enhancement that will make this easier. #699 is also relevant here.

  2. joemanfoo commented on Jul 21, 2017

    @joemanfoo

    I use the extend (1) method for enlarging the output image with appended images by overlayWith (2)

  3. lovell commented on Aug 7, 2017

    @lovell
    Owner

    @Bnaya Hope this answered your question. Please subscribe to the linked issues for updates should you be interested.

  4. Bnaya commented on Aug 7, 2017

    @Bnaya
    Author

    Will do, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions