Update media types
This commit is contained in:
parent
0fa2a7fa20
commit
36ccd43fc3
@ -15,13 +15,17 @@
|
||||
*
|
||||
* @param {{
|
||||
* imageInputFile: { name:string },
|
||||
* maxWidth: number,
|
||||
* imagePreviewNode: HTMLImageElement,
|
||||
* maxWidth?: number,
|
||||
* imagePreviewNode?: HTMLImageElement,
|
||||
* }} params - Single object passed
|
||||
*
|
||||
* @returns { Promise<FunctionReturn> } - Return Object
|
||||
*/
|
||||
module.exports = async function imageInputFileToBase64({ imageInputFile, maxWidth, imagePreviewNode }) {
|
||||
module.exports = async function imageInputFileToBase64({
|
||||
imageInputFile,
|
||||
maxWidth,
|
||||
imagePreviewNode,
|
||||
}) {
|
||||
/**
|
||||
* Make https request
|
||||
*
|
||||
@ -58,8 +62,14 @@ module.exports = async function imageInputFileToBase64({ imageInputFile, maxWidt
|
||||
if (MAX_WIDTH) {
|
||||
const scaleSize = MAX_WIDTH / img.naturalWidth;
|
||||
|
||||
canvas.width = img.naturalWidth < MAX_WIDTH ? img.naturalWidth : MAX_WIDTH;
|
||||
canvas.height = img.naturalWidth < MAX_WIDTH ? img.naturalHeight : img.naturalHeight * scaleSize;
|
||||
canvas.width =
|
||||
img.naturalWidth < MAX_WIDTH
|
||||
? img.naturalWidth
|
||||
: MAX_WIDTH;
|
||||
canvas.height =
|
||||
img.naturalWidth < MAX_WIDTH
|
||||
? img.naturalHeight
|
||||
: img.naturalHeight * scaleSize;
|
||||
} else {
|
||||
canvas.width = img.naturalWidth;
|
||||
canvas.height = img.naturalHeight;
|
||||
|
@ -14,20 +14,26 @@
|
||||
*
|
||||
* @param {{
|
||||
* imageInput: HTMLInputElement,
|
||||
* maxWidth: number,
|
||||
* mimeType: [string='image/jpeg']
|
||||
* maxWidth?: number,
|
||||
* mimeType?: [string='image/jpeg']
|
||||
* }} params - Single object passed
|
||||
*
|
||||
* @returns { Promise<FunctionReturn> } - Return Object
|
||||
*/
|
||||
module.exports = async function imageInputToBase64({ imageInput, maxWidth, mimeType }) {
|
||||
module.exports = async function imageInputToBase64({
|
||||
imageInput,
|
||||
maxWidth,
|
||||
mimeType,
|
||||
}) {
|
||||
/**
|
||||
* Make https request
|
||||
*
|
||||
* @description make a request to datasquirel.com
|
||||
*/
|
||||
try {
|
||||
let imagePreviewNode = document.querySelector(`[data-imagepreview='image']`);
|
||||
let imagePreviewNode = document.querySelector(
|
||||
`[data-imagepreview='image']`
|
||||
);
|
||||
let imageName = imageInput.files[0].name.replace(/\..*/, "");
|
||||
let imageDataBase64;
|
||||
|
||||
@ -58,8 +64,14 @@ module.exports = async function imageInputToBase64({ imageInput, maxWidth, mimeT
|
||||
if (MAX_WIDTH) {
|
||||
const scaleSize = MAX_WIDTH / img.naturalWidth;
|
||||
|
||||
canvas.width = img.naturalWidth < MAX_WIDTH ? img.naturalWidth : MAX_WIDTH;
|
||||
canvas.height = img.naturalWidth < MAX_WIDTH ? img.naturalHeight : img.naturalHeight * scaleSize;
|
||||
canvas.width =
|
||||
img.naturalWidth < MAX_WIDTH
|
||||
? img.naturalWidth
|
||||
: MAX_WIDTH;
|
||||
canvas.height =
|
||||
img.naturalWidth < MAX_WIDTH
|
||||
? img.naturalHeight
|
||||
: img.naturalHeight * scaleSize;
|
||||
} else {
|
||||
canvas.width = img.naturalWidth;
|
||||
canvas.height = img.naturalHeight;
|
||||
@ -71,7 +83,9 @@ module.exports = async function imageInputToBase64({ imageInput, maxWidth, mimeT
|
||||
const srcEncoded = canvas.toDataURL(MIME_TYPE, QUALITY);
|
||||
|
||||
if (imagePreviewNode) {
|
||||
document.querySelectorAll(`[data-imagepreview='image']`).forEach((img) => {
|
||||
document
|
||||
.querySelectorAll(`[data-imagepreview='image']`)
|
||||
.forEach((img) => {
|
||||
img.src = srcEncoded;
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "datasquirel",
|
||||
"version": "1.9.5",
|
||||
"version": "1.9.6",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
|
9
publish.sh
Normal file
9
publish.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
msg="Updates"
|
||||
else
|
||||
msg="$1"
|
||||
fi
|
||||
|
||||
git add . && git commit -m "$msg" && git push && npm publish
|
Loading…
Reference in New Issue
Block a user