Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bugs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ patched 176559 client basic
patched 188359 client basic
patched 197260 client basic
previous 206540 26.3-snapshot-8
patched 207091 client basic
patched 210318 client basic
patched 211561 client basic
patched 215531 client basic
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright (C) 2026 The Debugify Contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
package dev.isxander.debugify.client.fixes.mc207091;

import dev.isxander.debugify.Debugify;

import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Iterator;

public final class ScreenshotCompression {
private ScreenshotCompression() {}

public static void compress(File screenshot) {
if (screenshot == null || !screenshot.isFile() || !screenshot.getName().endsWith(".png")) {
return;
}

File parent = screenshot.getParentFile();
if (parent == null || !"screenshots".equals(parent.getName())) {
return;
}

Path original = screenshot.toPath();
Path compressed = null;
try {
long originalSize = Files.size(original);
BufferedImage image = ImageIO.read(screenshot);
if (image == null) {
return;
}

Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("PNG");
if (!writers.hasNext()) {
return;
}

ImageWriter writer = writers.next();
try {
compressed = Files.createTempFile(parent.toPath(), "debugify-screenshot-", ".png");
try (ImageOutputStream output = ImageIO.createImageOutputStream(compressed.toFile())) {
if (output == null) {
throw new IOException("Could not create screenshot compression output stream");
}

writer.setOutput(output);
ImageWriteParam parameters = writer.getDefaultWriteParam();
if (parameters.canWriteCompressed()) {
parameters.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
String[] compressionTypes = parameters.getCompressionTypes();
if (compressionTypes != null && compressionTypes.length > 0) {
parameters.setCompressionType(compressionTypes[0]);
}
parameters.setCompressionQuality(0.0F);
}

writer.write(null, new IIOImage(image, null, null), parameters);
}
} finally {
writer.dispose();
}

if (Files.size(compressed) < originalSize) {
try {
Files.move(compressed, original, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
} catch (AtomicMoveNotSupportedException ignored) {
Files.move(compressed, original, StandardCopyOption.REPLACE_EXISTING);
}
compressed = null;
}
} catch (IOException | RuntimeException exception) {
Debugify.LOGGER.warn("Failed to compress screenshot {}", screenshot, exception);
} finally {
if (compressed != null) {
try {
Files.deleteIfExists(compressed);
} catch (IOException exception) {
Debugify.LOGGER.warn("Failed to remove temporary screenshot file {}", compressed, exception);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2026 The Debugify Contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
package dev.isxander.debugify.client.mixins.basic.mc207091;

import dev.isxander.debugify.client.fixes.mc207091.ScreenshotCompression;
import dev.isxander.debugify.fixes.BugFix;
import dev.isxander.debugify.fixes.FixCategory;
import com.mojang.blaze3d.platform.NativeImage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.io.File;

@BugFix(
id = "MC-207091",
category = FixCategory.BASIC,
env = BugFix.Env.CLIENT,
enabled = false,
description = "Re-compresses saved PNG screenshots without changing their dimensions or pixel data"
)
@Mixin(NativeImage.class)
public class NativeImageMixin {
@Inject(method = "writeToFile(Ljava/io/File;)V", at = @At("RETURN"))
private void debugify$compressScreenshot(File file, CallbackInfo ci) {
ScreenshotCompression.compress(file);
}
}
1 change: 1 addition & 0 deletions src/client/resources/debugify.client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"minVersion": "0.5.3"
},
"client": [
"basic.mc207091.NativeImageMixin",
"basic.mc105068.LivingEntityMixin",
"basic.mc115092.SquidRendererMixin",
"basic.mc116379.FishingHookRendererMixin",
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/debugify/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@
"debugify.fix_effect.mc-272431": "Prevents zero and one-cycling the dragon as the dragon will no longer slowly perch on the end fountain or above travel nodes.",
"debugify.fix_explanation.mc-297837": "Only use horizontal distance when calculating which waypoint transmitter to use, since large distances use azimuthal distance, which guesses pitch via horizon angle.",
"debugify.fix_effect.mc-297837": "This allows clients to get exact position of players even when they are far away, but only vertically.",
"debugify.fix_explanation.mc-299115": "The owner's reference is converted to an entity on deflection. This conversion fails if the owner is offline."
"debugify.fix_explanation.mc-299115": "The owner's reference is converted to an entity on deflection. This conversion fails if the owner is offline.",
"debugify.fix_explanation.mc-207091": "Re-compresses saved PNG screenshots without changing their dimensions or pixel data. Disabled by default."
}