mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Recreate card thumbnails wrongly encoded as CMYK JPEG from PNG. Fixes
#1589.
This commit is contained in:
parent
0c12998405
commit
63ca80fc86
1 changed files with 20 additions and 9 deletions
|
@ -113,15 +113,15 @@ public class ImageCache {
|
|||
}
|
||||
if (exists) {
|
||||
LOGGER.debug("loading thumbnail for " + key + ", path=" + thumbnailPath);
|
||||
return loadImage(thumbnailFile);
|
||||
} else {
|
||||
BufferedImage image = loadImage(file);
|
||||
image = getWizardsCard(image);
|
||||
if (image == null) {
|
||||
return null;
|
||||
BufferedImage thumbnailImage = loadImage(thumbnailFile);
|
||||
if (thumbnailImage == null) { // thumbnail exists but broken for some reason
|
||||
LOGGER.warn("failed loading thumbnail for " + key + ", path=" + thumbnailPath
|
||||
+ ", thumbnail file is probably broken, attempting to recreate it...");
|
||||
thumbnailImage = makeThumbnailByFile(key, file, thumbnailPath);
|
||||
}
|
||||
LOGGER.debug("creating thumbnail for " + key);
|
||||
return makeThumbnail(image, thumbnailPath);
|
||||
return thumbnailImage;
|
||||
} else {
|
||||
return makeThumbnailByFile(key, file, thumbnailPath);
|
||||
}
|
||||
} else {
|
||||
return getWizardsCard(loadImage(file));
|
||||
|
@ -138,6 +138,16 @@ public class ImageCache {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BufferedImage makeThumbnailByFile(String key, TFile file, String thumbnailPath) {
|
||||
BufferedImage image = loadImage(file);
|
||||
image = getWizardsCard(image);
|
||||
if (image == null) {
|
||||
return null;
|
||||
}
|
||||
LOGGER.debug("creating thumbnail for " + key);
|
||||
return makeThumbnail(image, thumbnailPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -271,7 +281,8 @@ public class ImageCache {
|
|||
}
|
||||
try {
|
||||
try (TFileOutputStream outputStream = new TFileOutputStream(imageFile)) {
|
||||
ImageIO.write(image, "jpg", outputStream);
|
||||
String format = image.getColorModel().getNumComponents() > 3 ? "png" : "jpg";
|
||||
ImageIO.write(image, format, outputStream);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOGGER.error(e, e);
|
||||
|
|
Loading…
Reference in a new issue