VectorizeJPG – Convert JPG to SVG
/* — CSS SEPARATION START — */
@import url(‘https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&family=Space+Mono:wght@400;700&display=swap’);:root {
–primary: #EA580C; /* Orange-600 */
–bg-dark: #0F172A;
}body {
font-family: ‘Inter’, sans-serif;
transition: background-color 0.3s, color 0.3s;
}/* Transparency Checkerboard */
.checkerboard {
background-color: #ffffff;
background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
background-size: 20px 20px;
background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}
.dark .checkerboard {
background-color: #1e293b;
background-image: linear-gradient(45deg, #334155 25%, transparent 25%),
linear-gradient(-45deg, #334155 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, #334155 75%),
linear-gradient(-45deg, transparent 75%, #334155 75%);
}/* Loading Spinner */
.loader {
border: 3px solid #f3f3f3;
border-radius: 50%;
border-top: 3px solid #EA580C;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
}@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}/* Dark Mode */
.dark body {
background-color: var(–bg-dark);
color: #F9FAFB;
}
.dark .card {
background-color: #1E293B;
border-color: #334155;
}
.dark input {
background-color: #334155;
color: white;
border-color: #475569;
}
/* — CSS SEPARATION END — */
tailwind.config = {
darkMode: ‘class’,
theme: {
extend: {
colors: {
primary: ‘#EA580C’,
}
}
}
}
Turn raster JPG photos into infinitely scalable SVG vectors. Ideal for converting sketches, logos, and simple illustrations.
Vector Settings
Color Precision
16
Higher = More photorealistic, larger file size.
Smoothing (Blur)
1
Helps smooth out JPG artifacts.
Tip: Complex photos will result in large SVG files. Use “Simplify” to reduce node count.
Start Over
Drop JPG Image Here Convert raster to vectors
Select Image
// — JAVASCRIPT SEPARATION START —// DOM Elements
const dropzone = document.getElementById(‘dropzone’);
const fileInput = document.getElementById(‘fileInput’);
const resultArea = document.getElementById(‘result-area’);
const previewOriginal = document.getElementById(‘preview-original’);
const previewVectorContainer = document.getElementById(‘preview-vector-container’);
const vectorLoader = document.getElementById(‘vector-loader’);
const btnDlSvg = document.getElementById(‘btn-dl-svg’);
const traceColors = document.getElementById(‘trace-colors’);
const traceColorsVal = document.getElementById(‘trace-colors-val’);
const traceBlur = document.getElementById(‘trace-blur’);
const traceBlurVal = document.getElementById(‘trace-blur-val’);let uploadedRaster = null;
let currentSVGString = null;
let isDarkMode = false;// — Event Listeners —
dropzone.addEventListener(‘click’, () => fileInput.click());
dropzone.addEventListener(‘dragover’, (e) => { e.preventDefault(); dropzone.classList.add(‘border-orange-600’); });
dropzone.addEventListener(‘dragleave’, () => dropzone.classList.remove(‘border-orange-600’));
dropzone.addEventListener(‘drop’, (e) => {
e.preventDefault();
dropzone.classList.remove(‘border-orange-600’);
if(e.dataTransfer.files.length) handleFile(e.dataTransfer.files[0]);
});
fileInput.addEventListener(‘change’, (e) => {
if(e.target.files.length) handleFile(e.target.files[0]);
});// Settings Updates
traceColors.addEventListener(‘input’, (e) => {
traceColorsVal.innerText = e.target.value;
if(uploadedRaster) vectorizeImage();
});
traceBlur.addEventListener(‘input’, (e) => {
traceBlurVal.innerText = e.target.value;
if(uploadedRaster) vectorizeImage();
});// — Functions —function handleFile(file) {
if(!file.type.startsWith(‘image/’)) {
alert(‘Please upload a valid image file.’);
return;
}
const url = URL.createObjectURL(file);
uploadedRaster = url;
previewOriginal.src = url;
resultArea.classList.remove(‘hidden’);
vectorizeImage();
}function vectorizeImage() {
// Reset
previewVectorContainer.innerHTML = ”;
previewVectorContainer.appendChild(vectorLoader);
vectorLoader.classList.remove(‘hidden’);
btnDlSvg.disabled = true;// Config
const options = {
numberofcolors: parseInt(traceColors.value),
blurradius: parseFloat(traceBlur.value),
pathomit: 8,
scale: 1,
strokewidth: 0 // JPGs usually don’t have clear outlines for strokes
};// Run Tracer
ImageTracer.imageToSVG(uploadedRaster, function(svgstr) {
vectorLoader.classList.add(‘hidden’);
currentSVGString = svgstr;
// Inject
previewVectorContainer.innerHTML = svgstr;
const svgEl = previewVectorContainer.querySelector(‘svg’);
if(svgEl) {
svgEl.setAttribute(‘width’, ‘100%’);
svgEl.setAttribute(‘height’, ‘100%’);
svgEl.style.maxHeight = ‘100%’;
}btnDlSvg.disabled = false;
}, options);
}function downloadSVG() {
if(!currentSVGString) return;
const blob = new Blob([currentSVGString], {type: ‘image/svg+xml’});
const url = URL.createObjectURL(blob);
const a = document.createElement(‘a’);
a.href = url;
a.download = ‘vectorized_image.svg’;
a.click();
URL.revokeObjectURL(url);
}function resetAll() {
uploadedRaster = null;
currentSVGString = null;
fileInput.value = ”;
resultArea.classList.add(‘hidden’);
previewOriginal.src = ”;
previewVectorContainer.innerHTML = ”;
previewVectorContainer.appendChild(vectorLoader);
}function toggleDarkMode() {
isDarkMode = !isDarkMode;
document.documentElement.classList.toggle(‘dark’);
const icon = document.getElementById(‘theme-icon’);
if(isDarkMode) {
icon.classList.remove(‘fa-moon’);
icon.classList.add(‘fa-sun’);
} else {
icon.classList.remove(‘fa-sun’);
icon.classList.add(‘fa-moon’);
}
}// — JAVASCRIPT SEPARATION END —
Using JPG to SVG Converter The JPG to SVG Converter utility is designed for image and graphics tasks. Check the on-page controls for available formats, limits and options. Always review the output for accuracy before sharing or publishing it.
Practical tips Keep your original files or source information as a backup. Choose suitable options using the controls provided by this tool. Check the generated result and retry with different settings if needed. Explore related tools Image Compressor and Image Resizer are available for related tasks.