diff --git a/client/pom.xml b/client/pom.xml index d6191b83..4a09dda8 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -80,6 +80,11 @@ org.eclipse.jetty jetty-servlet + + com.github.usefulness + webp-imageio + 0.9.0 + diff --git a/client/src/main/java/ctbrec/ui/sites/stripchat/AbstractStripchatUpdateService.java b/client/src/main/java/ctbrec/ui/sites/stripchat/AbstractStripchatUpdateService.java index fe77dc4d..69e67172 100644 --- a/client/src/main/java/ctbrec/ui/sites/stripchat/AbstractStripchatUpdateService.java +++ b/client/src/main/java/ctbrec/ui/sites/stripchat/AbstractStripchatUpdateService.java @@ -19,7 +19,7 @@ public abstract class AbstractStripchatUpdateService extends PaginatedScheduledS if (timestamp == 0) { 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 createTags(JSONObject model) { diff --git a/client/src/main/java/ctbrec/ui/tabs/ThumbCell.java b/client/src/main/java/ctbrec/ui/tabs/ThumbCell.java index 14d035eb..889815ba 100644 --- a/client/src/main/java/ctbrec/ui/tabs/ThumbCell.java +++ b/client/src/main/java/ctbrec/ui/tabs/ThumbCell.java @@ -26,6 +26,7 @@ import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; +import javafx.embed.swing.SwingFXUtils; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Cursor; @@ -61,6 +62,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import javax.imageio.ImageIO; + import static ctbrec.Model.State.OFFLINE; import static ctbrec.Model.State.ONLINE; import static ctbrec.io.HttpConstants.*; @@ -431,11 +434,16 @@ public class ThumbCell extends StackPane { .build(); try (Response resp = model.getSite().getHttpClient().executeWithCache(req)) { if (resp.isSuccessful()) { - double width = 480; - double height = width * imgAspectRatio; + // double width = 480; + // double height = width * imgAspectRatio; 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.isError()) { + throw new IOException(img.getException()); + } Platform.runLater(() -> { iv.setImage(img); setThumbWidth(Config.getInstance().getSettings().thumbWidth);