Code Monkey home page Code Monkey logo

Comments (8)

zhanziyang avatar zhanziyang commented on May 28, 2024 2

a better one: https://jsfiddle.net/jdcvpvty/2/

from vue-croppa.

zhanziyang avatar zhanziyang commented on May 28, 2024 2

@Tarasovych Yes, you can use canvas-color="white" to make transparent background of png images white

from vue-croppa.

hawkeye64 avatar hawkeye64 commented on May 28, 2024

Yes, that was exactly it. I changes the :canvas-color to 'transparent' and now existing PNGs retain their transparency.

The downside of this is that you can no longer see the size of the canvas.

My suggestion is to add the following properties:
:border="true"
:border-color="default"
:border-size="2"

Up to you. I can live with it the way it is now, so just a suggestion.

All around, good work! Most other components that do the same were just way too bulky.

from vue-croppa.

zhanziyang avatar zhanziyang commented on May 28, 2024

Thank you for your support :))))) It's my first open source project that's actually useful for others lol.

Yes, it was intended that :canvas-color should fill the "white space" of the image. If you'd like it to be transparent and also be able to see the canvas zone, you can add some css styles on .croppa-container. Like this: https://jsfiddle.net/jdcvpvty/1/

Note that the css styles won't have effects on the output image, while :canvas-color will.

from vue-croppa.

hawkeye64 avatar hawkeye64 commented on May 28, 2024

Excellent! Thanks!

from vue-croppa.

Tarasovych avatar Tarasovych commented on May 28, 2024

@zhanziyang I faced this problem today, may I ask if setting canvas-color="white" is good solution for keeping png images transparent background white, but not black (according to the question, default canvas background is black)?
I mean, when I left canvas-color="transparent" and 'image/jpeg' at generateBlob(), I got black background as a result, where there is actually no background because of png format.
When I went canvas-color="white" and kept 'image/jpeg' at generateBlob(), I got white background where it might be transparent.
My backend stores all images in jpeg anyway, so I need white where it's transparent, if png is uploaded. Thank you.

from vue-croppa.

nothingismagick avatar nothingismagick commented on May 28, 2024

1 1/2 years later I'd just like to say thanks for this!

from vue-croppa.

hawkeye64 avatar hawkeye64 commented on May 28, 2024

@nothingismagick :)

from vue-croppa.

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.