mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-24 07:20:16 +05:30
feat(image): implement sharp-based image operations backend
Add src/main/ImageOperations.js (convert/resize/compress/rotate via
sharp), modeled on PDFOperations.js's executeOperation dispatcher.
Wire ipcMain.handle('process-image-operation', ...) in main.js using
sanitizeErrorMessage() on error paths, and replace the 5 stale/unused
image-* channel names in preload.js's ALLOWED_SEND_CHANNELS with
process-image-operation + select-image-folder (mirroring
select-pdf-folder for a later batch-UI task).
Amit Haridas
This commit is contained in:
+29
@@ -5,6 +5,7 @@ const os = require('os');
|
||||
const { execFile } = require('child_process');
|
||||
const WordTemplateExporter = require('./wordTemplateExporter');
|
||||
const PDFOperations = require('./main/PDFOperations');
|
||||
const ImageOperations = require('./main/ImageOperations');
|
||||
const GitOperations = require('./main/GitOperations');
|
||||
const PdfFontHeader = require('./main/PdfFontHeader');
|
||||
const MonospaceFontConfig = require('./main/MonospaceFontConfig');
|
||||
@@ -4620,6 +4621,34 @@ ipcMain.on('select-pdf-folder', (event, inputId) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ========================================
|
||||
// IMAGE OPERATIONS — delegates to main/ImageOperations.js
|
||||
// ========================================
|
||||
|
||||
ipcMain.handle('process-image-operation', async (event, { operation, data }) => {
|
||||
try {
|
||||
return await ImageOperations.executeOperation(operation, {
|
||||
...data,
|
||||
maxFileSize: MAX_FILE_SIZE,
|
||||
});
|
||||
} catch (error) {
|
||||
return { success: false, error: sanitizeErrorMessage(error.message) };
|
||||
}
|
||||
});
|
||||
|
||||
// IPC Handler for folder selection (for batch image operations)
|
||||
ipcMain.on('select-image-folder', (event, inputId) => {
|
||||
const folder = dialog.showOpenDialogSync(mainWindow, {
|
||||
properties: ['openDirectory'],
|
||||
});
|
||||
if (folder && folder[0]) {
|
||||
event.reply('image-folder-selected', {
|
||||
inputId,
|
||||
path: folder[0],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================
|
||||
// ASCII Art Generator Window
|
||||
// ============================================
|
||||
|
||||
Reference in New Issue
Block a user