Wednesday, September 13, 2023
HomeCSShtml - download photo with history making use of JavaScript

html – download photo with history making use of JavaScript

exactly how to download and install eliminate history photo with used history shade

I will certainly attempt to download and install photo yet download just eliminated backgrounded photo, not history shade that I used. as well as I am downloading and install the the very same photo with history yet its not functioning,
I require to post an png/jpeg photo data (photo a) as in this photo with any kind of dimension from web browser after that export it right into a brand-new photo with various dimension (photo b). As you can see, I wish to maintain photo a’s proportion as well as fill up the absent get rid of simple shade (eg. white). Exactly how do I do this making use of javascript?

EDIT: Sorry for the negative inquiry. I have actually currently modified my inquiry by including my very own code to resolve this issue. My job is making use of canvas to attract a white history initially after that attract the uploaded photo as long as it fits the canvas. After that I utilize Reimg.js to catch the canvas as well as download it.

Nonetheless, the issue is if I wish to utilize the caught photo, I need to post it once more. The listed below code is not what I desire. for downloading I’m utilizing this code

<< html >>.
<< head>>.
<< title>> Record<.
<< body>>.
<< div course=" container mt-4">>.
<< div course=" row mt-4">>.
<< div course=" col-md-12 card mt-4">>.
<< type>>.
<< div course=" form-group">
<> < tag for=" fileInput">> Select a Documents: <.
<< input id=" fileInput" course=" form-control"
kind=" data">
<> .
<< input course=" btn btn-primary m-1".
kind=" switch" onclick=" submitHandler()"
worth=" Upload">
<> .
<< img src="" id=" imggg">
<> < switch course=" btn btn-warning".
onclick=" downloadFile()">
> Download and install.

<< manuscript>>.
allow imageURL;

feature submitHandler() {
console.log(" click");
const fileInput = document.getElementById(' fileInput');
console.log( fileInput.files);
const photo = fileInput.files[0];

// Multipart data.
const formData = brand-new FormData();
formData.append(' image_file', photo);
formData.append(' dimension', 'automobile');

const apiKey='PASTE_YOUR_API_KEY';

bring('', {
approach:' ARTICLE',.
headers: {
' X-Api-Key': apiKey.
body: formData.
} )
. after that( feature( reponse) {
return reponse.blob().
} )
. after that( feature( ball) {
console.log( ball);
console.log( ball);
const link = URL.createObjectURL( ball);.
imageURL = link;.
const img = document.querySelector(" #imggg");.
img.src = link;.
} )
. catch();.

feature downloadFile() {
var a = document.createElement(' a');//<< a><> .
a.href = imageURL;.'naciasv.png';.
document.body.appendChild( a);.;.

document.body.removeChild( a);.


Most Popular

Recent Comments