Skip to content

Commit dac8a18

Browse files
committed
Include libwebp binaries in the package; renamed classes
1 parent bf73e7e commit dac8a18

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

src/main/java/net/sf/mcf2pdf/mcfelements/util/ImageUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
import com.drew.metadata.MetadataException;
4343
import com.drew.metadata.exif.ExifDirectoryBase;
4444

45-
import net.sf.mcf2pdf.mcfelements.util.webp.Qt5Webp;
46-
import net.sf.mcf2pdf.mcfelements.util.webp.Qt5WebpLib;
45+
import net.sf.mcf2pdf.mcfelements.util.webp.Webp;
46+
import net.sf.mcf2pdf.mcfelements.util.webp.WebpLib;
4747

4848
/**
4949
* Utility class for working with images in the context of the mcf2pdf project.
@@ -61,7 +61,7 @@ public final class ImageUtil {
6161

6262
public static final double SQRT_2 = Math.sqrt(2);
6363

64-
private static Qt5WebpLib qt5Library;
64+
private static WebpLib qt5Library;
6565

6666
private ImageUtil() {
6767
}
@@ -264,10 +264,10 @@ private static BufferedImage internalRead(File f) throws IOException {
264264
// special treatment for webp files
265265
if (f.getName().toLowerCase(Locale.US).endsWith(".webp")) {
266266
if (qt5Library == null) {
267-
qt5Library = Qt5Webp.loadLibrary();
267+
qt5Library = Webp.loadLibrary();
268268
}
269269

270-
return Qt5Webp.loadWebPImage(f, qt5Library);
270+
return Webp.loadWebPImage(f, qt5Library);
271271
}
272272

273273
return ImageIO.read(f);

src/main/java/net/sf/mcf2pdf/mcfelements/util/webp/Qt5Webp.java renamed to src/main/java/net/sf/mcf2pdf/mcfelements/util/webp/Webp.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.awt.image.DataBufferByte;
55
import java.io.File;
66
import java.io.FileInputStream;
7-
import java.io.FileNotFoundException;
87
import java.io.IOException;
98

109
import org.apache.commons.io.IOUtils;
@@ -13,34 +12,34 @@
1312
import com.sun.jna.Platform;
1413

1514
/**
16-
* Utility class to load the Qt5 dynamic library for the WebP file format from
17-
* the CEWE installation directory, and for convenient WebP image loading using
18-
* that library.
15+
* Utility class to load the dynamic library for the WebP file format from the
16+
* CEWE installation directory, and for convenient WebP image loading using that
17+
* library.
1918
*
2019
* @author Florian Albrecht
2120
*
22-
* @see Qt5WebpLib
21+
* @see WebpLib
2322
*
2423
*/
25-
public final class Qt5Webp {
24+
public final class Webp {
2625

27-
private Qt5Webp() {
26+
private Webp() {
2827
}
2928

3029
/**
3130
* Loads the WebP library. Under Windows, the library must be named
3231
* <code>libwebp.dll</code>, under Linux and Mac OS X, a
33-
* <code>libqwebp.so</code> is expected. It must be on the program's
34-
* classpath.
32+
* <code>libwebp.so</code> is expected. For Windows and Linux, the shared
33+
* library is included in the mcf2pdf package.
3534
*
36-
* @return The loaded Qt5 WebP library, as a dynamic Java JNA proxy.
35+
* @return The loaded WebP library, as a dynamic Java JNA proxy.
3736
*
3837
* @throws IOException
3938
* If the library cannot be found.
4039
*/
41-
public static Qt5WebpLib loadLibrary() throws IOException {
42-
String libName = Platform.isWindows() ? "libwebp.dll" : "libqwebp.so";
43-
return (Qt5WebpLib) Native.loadLibrary(libName, Qt5WebpLib.class);
40+
public static WebpLib loadLibrary() throws IOException {
41+
String libName = Platform.isWindows() ? "libwebp.dll" : "libwebp.so";
42+
return (WebpLib) Native.loadLibrary(libName, WebpLib.class);
4443
}
4544

4645
/**
@@ -56,7 +55,7 @@ public static Qt5WebpLib loadLibrary() throws IOException {
5655
* @throws IOException
5756
* If the image could not be loaded.
5857
*/
59-
public static BufferedImage loadWebPImage(File webpImageFile, Qt5WebpLib library) throws IOException {
58+
public static BufferedImage loadWebPImage(File webpImageFile, WebpLib library) throws IOException {
6059
int[] aw = new int[1];
6160
int[] ah = new int[1];
6261

src/main/java/net/sf/mcf2pdf/mcfelements/util/webp/Qt5WebpLib.java renamed to src/main/java/net/sf/mcf2pdf/mcfelements/util/webp/WebpLib.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
/**
77
* JNA interface with all required methods to be dynamically linked and accessed
8-
* from the shared Qt5 library for WebP access. Derived from <a href=
8+
* from the shared WebP library. Derived from <a href=
99
* "https://code.woboq.org/qt5/qtimageformats/src/3rdparty/libwebp/src/webp/decode.h.html">https://code.woboq.org/qt5/qtimageformats/src/3rdparty/libwebp/src/webp/decode.h.html</a>
1010
*
1111
* @author Florian Albrecht
1212
*
1313
*/
14-
public interface Qt5WebpLib extends Library {
14+
public interface WebpLib extends Library {
1515

1616
int WebPGetInfo(byte[] data, int data_size, int[] width, int[] height);
1717

378 KB
Binary file not shown.
468 KB
Binary file not shown.

0 commit comments

Comments
 (0)