Skip to content

Instantly share code, notes, and snippets.

@letrastudio
Last active May 21, 2021 11:15
Show Gist options
  • Save letrastudio/33853ea7ae043c0c4fc34a73d7b16a27 to your computer and use it in GitHub Desktop.
Save letrastudio/33853ea7ae043c0c4fc34a73d7b16a27 to your computer and use it in GitHub Desktop.
function imageType(format) {
switch (format.toUpperCase()) {
case "JPEG":
case "JPG":
return { format: "JPEG", ext: "jpg", mimetype: "image/jpeg" }
case "PNG":
return { format: "PNG", ext: "png", mimetype: "image/png" }
case "GIF":
return { format: "GIF", ext: "gif", mimetype: "image/gif" }
case "SVG":
return { format: "SVG", ext: "svg", mimetype: "image/svg+xml" }
case "ICO":
return { format: "ICO", ext: "ico", mimetype: "image/x-icon" }
case "WEBP":
return { format: "WEBP", ext: "webp", mimetype: "image/webp" }
case "TIFF":
case "TIF":
return { format: "TIFF", ext: "tif", mimetype: "image/tiff" }
case "PSD":
return { format: "PSD", ext: "psd", mimetype: "image/vnd.adobe.photoshop" }
case "PDF":
return { format: "PDF", ext: "pdf", mimetype: "application/pdf" }
default:
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment