Biblioteca JavaScript para convertidor de imágenes multifuncional-Reimg. js
| Autor: | gillyb |
|---|---|
| Views Total: | 1,965 |
| Sitio oficial: | Ir a la web |
| Actualizado: | September 6, 2015 |
| Licencia: | MIT |
Vista prévia
Descripción
Reimg. js es una biblioteca JavaScript muy pequeña para convertir imágenes de lienzo o SVG en diferentes formatos (Base64, PNG, imagen HTML, etc.).
Funcionamiento
Descargue y cargue el archivo de JavaScript reimg. js en su página HTML.
<script src="reimg.js"></script>
Convierta el lienzo a Base64.
function convertCanvasToBase64() {
var base64 = ReImg.fromCanvas(document.querySelector('canvas')).toBase64();
var output = document.querySelector('.output');
output.innerText = '';
output.innerText = base64;
} Convertir lienzo a HTML IMG elemento.
function convertCanvasToImgElement() {
var imgElement = ReImg.fromCanvas(document.querySelector('canvas')).toImg();
var output = document.querySelector('.output');
output.innerText = '';
output.appendChild(imgElement);
} Convierta Canvas a PNG.
function convertCanvasToPng() {
var img = ReImg.fromCanvas(document.querySelector('canvas')).toPng();
var output = document.querySelector('.output');
output.innerHTML = '';
output.appendChild(img);
} Convierta SVG a Base64.
function convertSvgToBase64() {
var base64 = ReImg.fromSvg(document.querySelector('svg')).toBase64();
var output = document.querySelector('.output');
output.innerText = '';
output.innerText = base64;
} Convierta SVG en lienzo.
function convertSvgToCanvas() {
var svgElement = document.querySelector('svg');
ReImg.fromSvg(svgElement).toCanvas(function(canvas) {
var output = document.querySelector('.output');
output.innerHtml = '';
output.appendChild(canvas);
});
} Convertir SVG a HTML IMG elemento.
function convertSvgToImgElement() {
var imgElement = ReImg.fromSvg(document.querySelector('svg')).toImg();
var output = document.querySelector('.output');
output.innerText = '';
output.appendChild(imgElement);
} Convierta SVG a PNG.
function convertSvgToPng() {
var svgElement = document.querySelector('svg');
var img = ReImg.fromSvg(svgElement).toPng();
var output = document.querySelector('.output');
output.innerHTML = '';
output.appendChild(img);
}





