Feat: extract exr preview file to be displayed on GUI

This commit is contained in:
harlekin
2023-01-06 14:53:06 +00:00
committed by Sheepit Renderfarm
parent 3cb7b5fc5f
commit 690ad36adb
5 changed files with 48 additions and 11 deletions

View File

@@ -40,6 +40,7 @@ import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -63,6 +64,8 @@ import java.util.regex.Pattern;
private String rendererMD5;
private String id;
private String outputImagePath;
private String previewImagePath;
private long outputImageSize;
private String path; // path inside of the archive
private String rendererCommand;
@@ -502,7 +505,7 @@ import java.util.regex.Pattern;
}
if (files.length != 0) {
new File(files[0].getAbsolutePath()).delete();
Arrays.stream(files).forEach( file -> new File(file.getAbsolutePath()).delete());
}
if (isServerBlockJob()) {
return Error.Type.RENDERER_KILLED_BY_SERVER;
@@ -547,6 +550,15 @@ import java.util.regex.Pattern;
return Error.Type.NOOUTPUTFILE;
}
else {
if (files.length == 2) {
Arrays.sort(files); //in case of an exr we end up with 2 images, the output as an exr and the preview as a jpg, we want to ensure the output comes first
String path = files[1].getAbsolutePath();
String extension = path.substring(path.lastIndexOf(".") + 1).toLowerCase();
if ("jpg".equals(extension)) {
setPreviewImagePath(files[1].getAbsolutePath());
}
}
setOutputImagePath(files[0].getAbsolutePath());
this.outputImageSize = new File(getOutputImagePath()).length();
log.debug(String.format("Job::render pictureFilename: %s, size: %d'", getOutputImagePath(), this.outputImageSize));