fix: remove the image-fragmentation surface
Closes #1300. Fragmentation was configurable, stored per event, served to the gallery client, and consumed by nothing. It was not unbuilt scaffolding — both halves exist and are individually coherent — but they were never connected, and they disagree: the server cut a fixed 3x3 grid while the client reassembled a 4x4 one, so wiring them together as they stood would have produced scrambled images rather than protection. Removed rather than finished, because finishing it buys nothing. The client fetches the whole image and then redraws it in pieces on a canvas, so the full original has already crossed the wire before any "protection" is applied — that is obfuscation, not a control. The per-fragment canvas work also lands on mobile, which is the memory profile under investigation in #1287. Goes: secureImageService.fragmentImageBuffer and its branch, the ?fragment=N delivery path and handleFragmentedImage in secureImages, the fragmented-JSON response in protectedImages, fragmentation_level in the gallery payload, the default_fragmentation_level setting, the PUT validator, the ProtectedImage fragment renderer, and the operator control with its strings in all eight locales. No migration. `events.fragmentation_level` and the app_settings row stay — dropping a column is irreversible and the stored values are harmless once nothing reads them. If they should go, that is a deliberate data decision and its own migration. `fragmentGrid` on AuthenticatedImage and the layouts is deliberately untouched: #1299 already removes it as part of the inert prop surface, and doing it here would only collide.
This commit is contained in:
@@ -175,8 +175,7 @@ class SecureImageService {
|
||||
quality = 85,
|
||||
maxWidth = 1920,
|
||||
maxHeight = 1080,
|
||||
addFingerprint = true,
|
||||
fragmentImage = false
|
||||
addFingerprint = true
|
||||
} = options;
|
||||
|
||||
try {
|
||||
@@ -187,7 +186,7 @@ class SecureImageService {
|
||||
|
||||
// For standard protection without fingerprinting, return original file
|
||||
// This avoids unnecessary recompression when no protection features are needed
|
||||
if (protectionLevel === 'standard' && !addFingerprint && !fragmentImage) {
|
||||
if (protectionLevel === 'standard' && !addFingerprint) {
|
||||
return await fs.readFile(imagePath);
|
||||
}
|
||||
|
||||
@@ -268,14 +267,7 @@ class SecureImageService {
|
||||
});
|
||||
}
|
||||
|
||||
const buffer = await image.toBuffer();
|
||||
|
||||
// Fragment image if requested (for canvas reconstruction)
|
||||
if (fragmentImage && protectionLevel === 'maximum') {
|
||||
return await this.fragmentImageBuffer(buffer, metadata);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
return await image.toBuffer();
|
||||
} catch (error) {
|
||||
logger.error('Error processing protected image:', error);
|
||||
// Return original on error
|
||||
@@ -283,51 +275,6 @@ class SecureImageService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fragment image into multiple pieces for canvas reconstruction
|
||||
*/
|
||||
async fragmentImageBuffer(buffer, metadata) {
|
||||
const { width, height } = metadata;
|
||||
const fragments = [];
|
||||
|
||||
// Create 3x3 grid of fragments
|
||||
const cols = 3;
|
||||
const rows = 3;
|
||||
const fragmentWidth = Math.floor(width / cols);
|
||||
const fragmentHeight = Math.floor(height / rows);
|
||||
|
||||
for (let row = 0; row < rows; row++) {
|
||||
for (let col = 0; col < cols; col++) {
|
||||
const left = col * fragmentWidth;
|
||||
const top = row * fragmentHeight;
|
||||
|
||||
const fragment = await sharp(buffer)
|
||||
.extract({
|
||||
left,
|
||||
top,
|
||||
width: fragmentWidth,
|
||||
height: fragmentHeight
|
||||
})
|
||||
.toBuffer();
|
||||
|
||||
fragments.push({
|
||||
index: row * cols + col,
|
||||
row,
|
||||
col,
|
||||
buffer: fragment,
|
||||
position: { left, top, width: fragmentWidth, height: fragmentHeight }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'fragmented',
|
||||
fragments,
|
||||
originalDimensions: { width, height },
|
||||
fragmentDimensions: { width: fragmentWidth, height: fragmentHeight, cols, rows }
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Log image access for security monitoring
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user