Commit b56aab52 authored by destin tati's avatar destin tati

test commit

parent 790060a1
...@@ -36,25 +36,19 @@ export default { ...@@ -36,25 +36,19 @@ export default {
const imageType = file.type || 'image/jpeg'; const imageType = file.type || 'image/jpeg';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader();
reader.readAsDataURL(file); reader.readAsDataURL(file);
reader.onload = (e) => { reader.onload = (e) => {
const img = new Image(); const img = new Image();
img.src = e.target.result; img.src = e.target.result;
img.onload = () => { img.onload = () => {
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
canvas.width = 1000; canvas.width = 1000;
canvas.height = 600; canvas.height = 600;
if (img.width < img.height) { if (img.width < img.height) {
canvas.width = 600; canvas.width = 600;
canvas.height = 1000; canvas.height = 1000;
} }
if (img.width > canvas.width || img.height > canvas.height) { if (img.width > canvas.width || img.height > canvas.height) {
ctx.drawImage(img, 0, 0, canvas.width, canvas.height); ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
ctx.canvas.toBlob( ctx.canvas.toBlob(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment