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

I'm getting some errors while using glitch-canvas #64

Open
k2helix opened this issue Jun 28, 2020 · 2 comments
Open

I'm getting some errors while using glitch-canvas #64

k2helix opened this issue Jun 28, 2020 · 2 comments
Assignees
Labels

Comments

@k2helix
Copy link

k2helix commented Jun 28, 2020

Hi, I'm using this module for my bot made in discord.js, and sometimes I get random errors like

Error: Invalid component ID 33 in SOS

Error: Invalid component ID 12 in SOS

Error: Bogus marker length

Error: Huffman table 0x03 was not defined

My code is:

const Discord = require('discord.js')
const Canvas = require('canvas')
const fs = require('fs')
const db = require('megadb')
const bsonDB = require("bsondb");
const { createCanvas, loadImage } = require('canvas');
const request = require('node-superfetch');
const glitch = require('glitch-canvas')



module.exports = {
  name: 'glitch',
  description: '',
  async execute(client, message, args) {
    let user = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member
    let image = user.user.displayAvatarURL({ format: 'jpeg', size: 1024 }) //url below
    const { body } = await request.get(image);
    const data = await loadImage(body);
    const canvas = createCanvas(data.width < 250 ? 278 : data.width, data.height < 250 ? 278 : data.height); //using this because I think it happens with small images
    const ctx = canvas.getContext('2d');
    ctx.drawImage(data, 0, 0, canvas.width, canvas.height);
    const attachment = canvas.toBuffer();
    glitch({ seed: Math.floor(Math.random() * 20), itinerations: Math.floor(Math.random() * 20), amount: Math.floor(Math.random() * 20) })
      .fromBuffer(attachment)
      .toBuffer()
      .then(function(glitchedBuffer) {
        message.channel.send({
          files: [{
            attachment: glitchedBuffer,
            name: 'glitch.jpeg'
          }]


        })
      }).catch(error => {
        message.channel.send('Please, use the command another time. ' + error)
      })


  }
}

Currently I'm using this image

Thanks in advance

@snorpey snorpey self-assigned this Jun 29, 2020
@snorpey snorpey added the bug label Jun 29, 2020
@snorpey
Copy link
Owner

snorpey commented Jun 30, 2020

hey @kevin2005015,
thank you for reporting this issue. It's great to see the library being used in other projects.

I've encountered similar issues in the past and was unable to fix them entirely, but I'll have another look. This might take a while though.

Any chance you could add the exact parameters that were used when the error occurs? This would make reproducing the issue so much easier.

Thanks again!

@k2helix
Copy link
Author

k2helix commented Jun 30, 2020

Hello again,

I tried logging the parameters, and I got some which happens everytime:

Seed 11, 12 itinerations, 15 amount, 84 quality (I checked this and happens everytime with the same error Unsupported marker type 0x26

Seed 19, 12 itinerations, 11 amount, 48 quality Error: Unsupported marker type 0x1c

Seed 1, 11 itinerations, 8 amount, 88 quality Error: Invalid component ID 20 in SOS

I got all these in a lot of attemps, so it doesn't happen usually.

Best regards

Edit: It only happens while using glitch-canvas, I tried in your website and it worked fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants