Giter Club home page Giter Club logo

Comments (6)

ngekoding avatar ngekoding commented on June 14, 2024 1

I try to use this lib https://www.npmjs.com/package/html-to-image, and it solve this issue & this one #144

[x] no need to rescaling
[x] use filter to remove download button

// element.classList.remove(...classLists);
// saveIcon?.classList.add("invisible");

htmlToImage.toBlob(element, {
  width: element.offsetWidth * 1.5,
  height: element.offsetHeight * 1.5,
  style: {
    transformOrigin: 'top left',
    width: element.offsetWidth + 'px',
    height: element.offsetHeight + 'px',
  },
  filter: (node) => !node.classList?.contains('button-save')
}).then(blob => {
  saveAs(blob, `quotes-nyandev-id-${Date.now()}.png`);
});

Sorry I can't make a complete code right now for PR. Maybe you can try it!

I was try to use the same configuration with current lib (dom-to-image-improved), but it still blurry.

from quotes.

ngekoding avatar ngekoding commented on June 14, 2024 1

Here is the different.

  • dom-to-image-improved (current result)

  • html-to-image (with configuration above)

from quotes.

nyancodeid avatar nyancodeid commented on June 14, 2024

unfortunately yes, we need to do that because we need to normalize our css before we turn it into a image

from quotes.

ngekoding avatar ngekoding commented on June 14, 2024

I haven't use that library, so there is no way to download without that animation?

from quotes.

nyancodeid avatar nyancodeid commented on June 14, 2024

I try to use this lib https://www.npmjs.com/package/html-to-image, and it solve this issue & this one #144

[x] no need to rescaling [x] use filter to remove download button

// element.classList.remove(...classLists);
// saveIcon?.classList.add("invisible");

htmlToImage.toBlob(element, {
  width: element.offsetWidth * 1.5,
  height: element.offsetHeight * 1.5,
  style: {
    transformOrigin: 'top left',
    width: element.offsetWidth + 'px',
    height: element.offsetHeight + 'px',
  },
  filter: (node) => !node.classList?.contains('button-save')
}).then(blob => {
  saveAs(blob, `quotes-nyandev-id-${Date.now()}.png`);
});

Sorry I can't make a complete code right now for PR. Maybe you can try it!

Cool, i just realize that html-to-image is fork version from the original dom-to-image and have been written into Typescript. I think we can use that.

I was try to use the same configuration with current lib (dom-to-image-improved), but it still blurry.

And i believe that blurry effect still exist in both library.

from quotes.

nyancodeid avatar nyancodeid commented on June 14, 2024

Awesome @ngekoding , the result is better than the current one. The resolution is also better. Nice one!

from quotes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.