Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image composting: Image artifacts or even error message 'Bus error: 10' #1849

Closed
rempargo opened this issue Aug 25, 2019 · 4 comments
Closed
Labels

Comments

@rempargo
Copy link

What is the output of running npx envinfo --binaries --languages --system --utilities?

System:
OS: macOS 10.14
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 13.53 GB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.7.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.5.0 - /usr/local/bin/npm
Utilities:
Make: 3.81 - /usr/bin/make
GCC: 10.14. - /usr/bin/gcc
Git: 2.20.1 - /usr/bin/git
Languages:
Bash: 3.2.57 - /bin/bash
Java: 11.0.2 - /usr/bin/javac
Perl: 5.18.2 - /usr/bin/perl
PHP: 7.1.19 - /usr/bin/php
Python: 2.7.10 - /usr/bin/python
Ruby: 2.6.3 - /Users/paulverschoor/.rvm/rubies/ruby-2.6.3/bin/ruby

What are the steps to reproduce?
running the code below, but each time using different arguments when calling the createImage() function.

What is the expected behaviour?
a new image which is composed by one other image ('smiley_24x24.png') that is repeated several times. For example the file '14x14_is_ok.png'

If I run createImage(14,14) I get the image that I expect.

What is the expected behaviour?

If I run createImage(15,15) I get an image with artifacts (last 16 composite images on the bottom are not there.
If I run createImage(16,16) I don't get an image at all, but I do get an error message Bus error: 10

The Bus error: 10 error is strange, because when I run just by it's own, I will get the error message and no image file

createImage(16,16)

But combined with a working call, It will create a 16x16 icons image (with the artifacts) and the 14x14. As if the correct output will cancel the previous error.

createImage(16,16)
createImage(14,14)

So there are two issues here, the image artifacts and the Bus error 10, but they seem very related to me.

Are you able to provide a standalone code sample, without other dependencies, that demonstrates this problem?

const sharp = require('sharp');
const fs = require('fs');

function createImage(designWidth,designHeigth){
    const pixelImage = 'smiley_24x24.png';
    var pixelSize     = 24 // size of the smiley
    var compositeImage =   sharp({
        create: {
          width: designWidth * pixelSize,
          height: designHeigth * pixelSize,
          channels: 3,
          background: { r: 200, g: 200, b: 200 } // grey background
        }
      })

      let images = []
  
      for (let y = 0; y < designHeigth; y++) {
        for (let x = 0; x < designWidth; x++) {
          images.push({input: pixelImage, left:x* pixelSize, top:y* pixelSize})
          }
        }   
     compositeImage.composite([...images.slice(0,209)])
     .png().toBuffer().then(data=>{
       fs.writeFileSync(`composite_test_${designWidth}x${designHeigth}.png`,data,'binary')
     })
}   
createImage(15,15)

Are you able to provide a sample image that helps explain the problem?
14x14_is_ok.png is like expected
14x14_is_ok

15x15_with_artifacts
15x15_with_artifacts

smiley_24x24.png is needed for the code.
smiley_24x24

@lovell
Copy link
Owner

lovell commented Aug 26, 2019

Hi, this looks like a stack overflow. See #1626 and #1708 for previous examples of this.

You can use sharp.cache(false) to disable libvips cache and reduce stack pressure. https://sharp.pixelplumbing.com/en/stable/api-utility/#cache

@lovell
Copy link
Owner

lovell commented Aug 26, 2019

Please subscribe to the future possible enhancement at #1580 that will provide a better solution for the problem described here.

@lovell
Copy link
Owner

lovell commented Sep 22, 2019

Hope this helped, please reopen with more details if not.

@lovell lovell closed this as completed Sep 22, 2019
@antoniogamiz
Copy link

I'm getting the same error, the provided solution it's not working in my case :( -> https://stackoverflow.com/questions/69181137/getting-bus-error-when-composing-a-lot-of-images-with-sharp?noredirect=1#comment122274290_69181137

@lovell lovell added question and removed triage labels Sep 15, 2021
Repository owner locked and limited conversation to collaborators Sep 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants