Compare commits

..
Author SHA1 Message Date
ShareVB 476172af16 Merge remote-tracking branch 'origin/main' into feat/removeexif 2024-08-24 10:41:18 +02:00
sharevb ba1b5bc5b6 feat(new tool): Exif Remover
Fix #1196
2024-08-24 10:31:48 +02:00
15 changed files with 773 additions and 200 deletions

No files matched your search

+1 -2
View File
@@ -121,7 +121,6 @@ declare module '@vue/runtime-core' {
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default']
MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default']
MarkdownToHtml: typeof import('./src/tools/markdown-to-html/markdown-to-html.vue')['default']
MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default']
MenuBar: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar.vue')['default']
MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default']
@@ -130,7 +129,6 @@ declare module '@vue/runtime-core' {
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
@@ -156,6 +154,7 @@ declare module '@vue/runtime-core' {
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
RemoveExif: typeof import('./src/tools/remove-exif/remove-exif.vue')['default']
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
+4 -3
View File
@@ -42,7 +42,7 @@
"@tiptap/starter-kit": "2.1.6",
"@tiptap/vue-3": "2.0.3",
"@types/figlet": "^1.5.8",
"@types/markdown-it": "^13.0.7",
"@types/memorystream": "^0.3.4",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
"@vueuse/core": "^10.3.0",
@@ -60,9 +60,9 @@
"dompurify": "^3.0.6",
"email-normalizer": "^1.0.0",
"emojilib": "^3.0.10",
"exif-be-gone": "^1.5.1",
"figlet": "^1.7.0",
"figue": "^1.2.0",
"flatten-anything": "^4.0.1",
"fuse.js": "^6.6.2",
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
@@ -72,9 +72,9 @@
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.10.28",
"lodash": "^4.17.21",
"markdown-it": "^14.0.0",
"marked": "^10.0.0",
"mathjs": "^11.9.1",
"memorystream": "^0.3.1",
"mime-types": "^2.1.35",
"monaco-editor": "^0.43.0",
"naive-ui": "^2.35.0",
@@ -137,6 +137,7 @@
"unplugin-icons": "^0.17.0",
"unplugin-vue-components": "^0.25.0",
"vite": "^4.4.9",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-pwa": "^0.16.0",
"vite-plugin-vue-markdown": "^0.23.5",
"vite-svg-loader": "^4.0.0",
+654 -74
View File
File diff suppressed because it is too large. Load diff
-2
View File
@@ -7,7 +7,6 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
import xmlHljs from 'highlight.js/lib/languages/xml';
import yamlHljs from 'highlight.js/lib/languages/yaml';
import iniHljs from 'highlight.js/lib/languages/ini';
import markdownHljs from 'highlight.js/lib/languages/markdown';
import { useCopy } from '@/composable/copy';
const props = withDefaults(
@@ -31,7 +30,6 @@ hljs.registerLanguage('html', xmlHljs);
hljs.registerLanguage('xml', xmlHljs);
hljs.registerLanguage('yaml', yamlHljs);
hljs.registerLanguage('toml', iniHljs);
hljs.registerLanguage('markdown', markdownHljs);
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
+14 -13
View File
@@ -1,6 +1,7 @@
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
import type { Ref } from 'vue';
import type { MaybeRef, Ref } from 'vue';
import _ from 'lodash';
import { get } from '@vueuse/core';
export {
getMimeTypeFromBase64,
@@ -75,21 +76,11 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
}
function useDownloadFileFromBase64(
{ source, filename, extension, fileMimeType }:
{ source: Ref<string>; filename?: string; extension?: string; fileMimeType?: string }) {
return {
download() {
downloadFromBase64({ sourceValue: source.value, filename, extension, fileMimeType });
},
};
}
function useDownloadFileFromBase64Refs(
{ source, filename, extension }:
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
return {
download() {
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
},
};
}
@@ -116,3 +107,13 @@ function previewImageFromBase64(base64String: string): HTMLImageElement {
return img;
}
function useDownloadFileFromBase64Refs(
{ source, filename, extension }:
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
return {
download() {
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
},
};
}
+8 -3
View File
@@ -7,9 +7,9 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as removeExif } from './remove-exif';
import { tool as xmlToJson } from './xml-to-json';
import { tool as jsonToXml } from './json-to-xml';
import { tool as markdownToHtml } from './markdown-to-html';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -113,7 +113,6 @@ export const toolsByCategory: ToolCategory[] = [
tomlToYaml,
xmlToJson,
jsonToXml,
markdownToHtml,
],
},
{
@@ -139,7 +138,13 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Images and videos',
components: [qrCodeGenerator, wifiQrCodeGenerator, svgPlaceholderGenerator, cameraRecorder],
components: [
qrCodeGenerator,
wifiQrCodeGenerator,
svgPlaceholderGenerator,
cameraRecorder,
removeExif,
],
},
{
name: 'Development',
-7
View File
@@ -1,7 +0,0 @@
declare module "flatten-anything" {
export function flatten(objectOrArray: {
[key in string]: any;
}, untilDepth?: number): {
[key in string]: any;
};
}
@@ -3,10 +3,6 @@ import { convertArrayToCsv, getHeaders } from './json-to-csv.service';
describe('json-to-csv service', () => {
describe('getHeaders', () => {
it('extracts all the keys from the array of nested objects', () => {
expect(getHeaders({ array: [{ a: { c: 1, d: 1 }, b: 2 }, { a: 3, c: 4 }] })).toEqual(['a.c', 'a.d', 'b', 'a', 'c']);
});
it('extracts all the keys from the array of objects', () => {
expect(getHeaders({ array: [{ a: 1, b: 2 }, { a: 3, c: 4 }] })).toEqual(['a', 'b', 'c']);
});
@@ -24,7 +20,7 @@ describe('json-to-csv service', () => {
];
expect(convertArrayToCsv({ arrayOrObject: array })).toMatchInlineSnapshot(`
expect(convertArrayToCsv({ array })).toMatchInlineSnapshot(`
"a,b
1,2
3,4"
@@ -37,7 +33,7 @@ describe('json-to-csv service', () => {
{ a: 3, c: 4 },
];
expect(convertArrayToCsv({ arrayOrObject: array })).toMatchInlineSnapshot(`
expect(convertArrayToCsv({ array })).toMatchInlineSnapshot(`
"a,b,c
1,2,
3,,4"
@@ -49,7 +45,7 @@ describe('json-to-csv service', () => {
{ a: null, b: 2 },
];
expect(convertArrayToCsv({ arrayOrObject: array })).toMatchInlineSnapshot(`
expect(convertArrayToCsv({ array })).toMatchInlineSnapshot(`
"a,b
null,2"
`);
@@ -61,7 +57,7 @@ describe('json-to-csv service', () => {
{ b: 3 },
];
expect(convertArrayToCsv({ arrayOrObject: array })).toMatchInlineSnapshot(`
expect(convertArrayToCsv({ array })).toMatchInlineSnapshot(`
"a,b
,2
,3"
@@ -73,7 +69,7 @@ describe('json-to-csv service', () => {
{ a: 'hello, world', b: 2 },
];
expect(convertArrayToCsv({ arrayOrObject: array })).toMatchInlineSnapshot(`
expect(convertArrayToCsv({ array })).toMatchInlineSnapshot(`
"a,b
\\"hello, world\\",2"
`);
@@ -84,32 +80,10 @@ describe('json-to-csv service', () => {
{ a: 'hello "world"', b: 2 },
];
expect(convertArrayToCsv({ arrayOrObject: array })).toMatchInlineSnapshot(`
expect(convertArrayToCsv({ array })).toMatchInlineSnapshot(`
"a,b
hello \\\\\\"world\\\\\\",2"
`);
});
it('converts an array of nested objects to a CSV string', () => {
const array = [
{ a: { c: 1, d: 1 }, b: 2 },
{ a: 3, c: 4 },
];
expect(convertArrayToCsv({ arrayOrObject: array })).toMatchInlineSnapshot(`
"a.c,a.d,b,a,c
1,1,2,,
,,,3,4"
`);
});
it('converts an object to a CSV string', () => {
const obj = { a: { c: 1, d: 1 }, b: 2 };
expect(convertArrayToCsv({ arrayOrObject: obj })).toMatchInlineSnapshot(`
"a.c,a.d,b
1,1,2"
`);
});
});
});
+3 -7
View File
@@ -1,11 +1,9 @@
import { flatten } from 'flatten-anything';
export { getHeaders, convertArrayToCsv };
function getHeaders({ array }: { array: Record<string, unknown>[] }): string[] {
const headers = new Set<string>();
array.forEach(item => Object.keys(flatten(item)).forEach(key => headers.add(key)));
array.forEach(item => Object.keys(item).forEach(key => headers.add(key)));
return Array.from(headers);
}
@@ -28,12 +26,10 @@ function serializeValue(value: unknown): string {
return valueAsString;
}
function convertArrayToCsv({ arrayOrObject }: { arrayOrObject: Record<string, unknown>[] | Record<string, unknown> }): string {
const array = !Array.isArray(arrayOrObject) ? [arrayOrObject] : arrayOrObject;
function convertArrayToCsv({ array }: { array: Record<string, unknown>[] }): string {
const headers = getHeaders({ array });
const rows = array.map(item => headers.map(header => serializeValue(flatten(item)[header])));
const rows = array.map(item => headers.map(header => serializeValue(item[header])));
return [headers.join(','), ...rows].join('\n');
}
+1 -1
View File
@@ -9,7 +9,7 @@ function transformer(value: string) {
if (value === '') {
return '';
}
return convertArrayToCsv({ arrayOrObject: JSON5.parse(value) });
return convertArrayToCsv({ array: JSON5.parse(value) });
}, '');
}
-12
View File
@@ -1,12 +0,0 @@
import { Markdown } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Markdown to HTML',
path: '/markdown-to-html',
description: 'Convert Markdown to Html and allow to print (as PDF)',
keywords: ['markdown', 'html', 'converter', 'pdf'],
component: () => import('./markdown-to-html.vue'),
icon: Markdown,
createdAt: new Date('2024-08-25'),
});
@@ -1,44 +0,0 @@
<script setup lang="ts">
import markdownit from 'markdown-it';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const inputMarkdown = ref('');
const outputHtml = computed(() => {
const md = markdownit();
return md.render(inputMarkdown.value);
});
function printHtml() {
const w = window.open();
if (w === null) {
return;
}
w.document.body.innerHTML = outputHtml.value;
w.print();
}
</script>
<template>
<div>
<c-input-text
v-model:value="inputMarkdown"
multiline raw-text
placeholder="Your Markdown content..."
rows="8"
autofocus
label="Your Markdown to convert:"
/>
<n-divider />
<n-form-item label="Output HTML:">
<TextareaCopyable :value="outputHtml" :word-wrap="true" language="html" />
</n-form-item>
<div flex justify-center>
<n-button @click="printHtml">
Print as PDF
</n-button>
</div>
</div>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { PictureInPictureOff } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Remove EXIF',
path: '/remove-exif',
description: 'Remove Exif from JPEG Files',
keywords: ['remove', 'exif', 'jpeg'],
component: () => import('./remove-exif.vue'),
icon: PictureInPictureOff,
createdAt: new Date('2024-07-14'),
});
+68
View File
@@ -0,0 +1,68 @@
<script setup lang="ts">
import { Buffer } from 'node:buffer';
import { Base64 } from 'js-base64';
import ExifTransformer from 'exif-be-gone';
import MemoryStream from 'memorystream';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle');
const file = ref<File | null>(null);
interface ToBufferMemoryStream extends MemoryStream {
toBuffer(): Buffer
}
const base64OutputFile = ref('');
const fileName = ref('');
const { download } = useDownloadFileFromBase64(
{
source: base64OutputFile,
filename: fileName,
extension: 'jpg',
});
async function onFileUploaded(uploadedFile: File) {
file.value = uploadedFile;
const fileBuffer = await uploadedFile.arrayBuffer();
fileName.value = `noexif_${uploadedFile.name}`;
status.value = 'processing';
try {
const inStream = MemoryStream.createReadStream(Buffer.from(fileBuffer));
const outStream = MemoryStream.createWriteStream();
const trans = new ExifTransformer();
await new Promise((resolve, _reject) => {
inStream.pipe(trans).pipe(outStream).on('finish', () => resolve(true));
});
const outFileBuffer = (outStream as ToBufferMemoryStream).toBuffer();
base64OutputFile.value = `data:image/File;base64,${Base64.fromUint8Array(outFileBuffer)}`;
status.value = 'done';
download();
}
catch (e) {
status.value = 'error';
}
}
</script>
<template>
<div>
<div style="flex: 0 0 100%">
<div mx-auto max-w-600px>
<c-file-upload title="Drag and drop a Image file here, or click to select a file" accept="image/*" @file-upload="onFileUploaded" />
</div>
</div>
<div mt-3 flex justify-center>
<c-alert v-if="status === 'error'" type="error">
An error occured processing {{ fileName }}
</c-alert>
<n-spin
v-if="status === 'processing'"
size="small"
/>
</div>
</div>
</template>
+2
View File
@@ -15,6 +15,7 @@ import { VitePWA } from 'vite-plugin-pwa';
import markdown from 'vite-plugin-vue-markdown';
import svgLoader from 'vite-svg-loader';
import { configDefaults } from 'vitest/config';
import { nodePolyfills } from 'vite-plugin-node-polyfills'
const baseUrl = process.env.BASE_URL ?? '/';
@@ -97,6 +98,7 @@ export default defineConfig({
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
}),
Unocss(),
nodePolyfills(),
],
base: baseUrl,
resolve: {