forked from j62/ctbrec
fix WEBP thumbs not loading
This commit is contained in:
parent
33f99488e2
commit
474abb33ff
|
@ -80,6 +80,11 @@
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.usefulness</groupId>
|
||||||
|
<artifactId>webp-imageio</artifactId>
|
||||||
|
<version>0.9.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
|
@ -19,7 +19,7 @@ public abstract class AbstractStripchatUpdateService extends PaginatedScheduledS
|
||||||
if (timestamp == 0) {
|
if (timestamp == 0) {
|
||||||
return model.optString("previewUrlThumbBig");
|
return model.optString("previewUrlThumbBig");
|
||||||
}
|
}
|
||||||
return MessageFormat.format("https://img.strpst.com/thumbs/{0}/{1}_jpg", String.valueOf(timestamp), String.valueOf(id));
|
return MessageFormat.format("https://img.strpst.com/thumbs/{0}/{1}", String.valueOf(timestamp), String.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> createTags(JSONObject model) {
|
protected List<String> createTags(JSONObject model) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.embed.swing.SwingFXUtils;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Cursor;
|
import javafx.scene.Cursor;
|
||||||
|
@ -61,6 +62,8 @@ import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import static ctbrec.Model.State.OFFLINE;
|
import static ctbrec.Model.State.OFFLINE;
|
||||||
import static ctbrec.Model.State.ONLINE;
|
import static ctbrec.Model.State.ONLINE;
|
||||||
import static ctbrec.io.HttpConstants.*;
|
import static ctbrec.io.HttpConstants.*;
|
||||||
|
@ -431,11 +434,16 @@ public class ThumbCell extends StackPane {
|
||||||
.build();
|
.build();
|
||||||
try (Response resp = model.getSite().getHttpClient().executeWithCache(req)) {
|
try (Response resp = model.getSite().getHttpClient().executeWithCache(req)) {
|
||||||
if (resp.isSuccessful()) {
|
if (resp.isSuccessful()) {
|
||||||
double width = 480;
|
// double width = 480;
|
||||||
double height = width * imgAspectRatio;
|
// double height = width * imgAspectRatio;
|
||||||
InputStream bodyStream = Objects.requireNonNull(resp.body(), "HTTP body is null").byteStream();
|
InputStream bodyStream = Objects.requireNonNull(resp.body(), "HTTP body is null").byteStream();
|
||||||
var img = new Image(bodyStream, width, height, preserveAspectRatio.get(), true);
|
// javafx supports only a few image formats (not webp, for example), so we go through ImageIO that does
|
||||||
|
var img = SwingFXUtils.toFXImage(ImageIO.read(bodyStream), null);
|
||||||
|
|
||||||
if (img.progressProperty().get() == 1.0) {
|
if (img.progressProperty().get() == 1.0) {
|
||||||
|
if (img.isError()) {
|
||||||
|
throw new IOException(img.getException());
|
||||||
|
}
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
iv.setImage(img);
|
iv.setImage(img);
|
||||||
setThumbWidth(Config.getInstance().getSettings().thumbWidth);
|
setThumbWidth(Config.getInstance().getSettings().thumbWidth);
|
||||||
|
|
Loading…
Reference in New Issue