Skip to content

Commit 974d5c6

Browse files
authored
Merge pull request #3857 from mapfish/ghci/backport/3856-to-3.33
[Backport 3.33] Add WebP support
2 parents 8452b00 + 715e999 commit 974d5c6

File tree

14 files changed

+94
-5
lines changed

14 files changed

+94
-5
lines changed

core/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ dependencies {
185185
'net.logstash.logback:logstash-logback-encoder:8.0',
186186
// For PDF/A
187187
'com.adobe.xmp:xmpcore:6.1.11',
188+
// For WebP images
189+
'com.twelvemonkeys.imageio:imageio-webp:3.12.0',
188190
)
189191

190192
implementation(
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.mapfish.print;
2+
3+
import com.twelvemonkeys.imageio.plugins.webp.WebPImageReaderSpi;
4+
import javax.annotation.PostConstruct;
5+
import javax.imageio.ImageIO;
6+
import javax.imageio.spi.IIORegistry;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
10+
/**
11+
* Initializes image plugins (initially for WebP support) at application startup.
12+
*
13+
* <p>This class registers the WebP image reader plugin with the Java ImageIO framework, enabling
14+
* support for WebP images. Typically used in a servlet context.
15+
*/
16+
public class ImageInit {
17+
private static final Logger LOGGER = LoggerFactory.getLogger(ImageInit.class);
18+
19+
/**
20+
* Initializes image plugins if the {@code mapfish.image.plugins} system property is set to {@code
21+
* true}. Registers additional image readers such as WebP.
22+
*/
23+
@PostConstruct
24+
public final void init() {
25+
if (System.getProperty("mapfish.image.plugins", "false").equals("true")) {
26+
LOGGER.info("Scanning for image plugins");
27+
ImageIO.scanForPlugins();
28+
IIORegistry.getDefaultInstance().registerServiceProvider(new WebPImageReaderSpi());
29+
}
30+
}
31+
}

core/src/main/webapp/WEB-INF/mapfish-print-servlet.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
</bean>
1717

1818
<bean id="versionInfo" class="org.mapfish.print.VersionInfo" lazy-init="false"/>
19+
<bean id="imageInit" class="org.mapfish.print.ImageInit" lazy-init="false"/>
1920
</beans>

docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
PRINT_YAML_MAX_ALIASES: '200'
1717
LOG_LEVEL: DEBUG
1818
JASPER_LOG_LEVEL: DEBUG
19+
JAVA_OPTS: '-Dmapfish.image.plugins=true'
1920

2021
tests:
2122
image: mapfish_print_builder

docs/src/main/resources/pages.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"pages": {
1212
"index": "Overview",
13+
"properties": "Properties",
1314
"jasperreports": "Jasper Reports",
1415
"api": "Web Protocol",
1516
"tableimages": "Configuration of tables with HTML images",

docs/src/main/resources/templates/_main.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@
4141
<a class="reference internal {{current_api}}" href="api.html">Web API</a>
4242
</li>
4343

44-
<li class="toctree-l1 {{current_attributes}}">
45-
<a class="reference internal {{current_attributes}}" href="attributes.html">Attributes</a>
46-
{{sub_nav_attributes}}
44+
<li class="toctree-l1 {{current_properties}}">
45+
<a class="reference internal {{current_properties}}" href="properties.html">Properties</a>
4746
</li>
4847

4948
<li class="toctree-l1 {{current_configuration}}">
@@ -53,6 +52,11 @@
5352
{{sub_nav_configuration}}
5453
</li>
5554

55+
<li class="toctree-l1 {{current_attributes}}">
56+
<a class="reference internal {{current_attributes}}" href="attributes.html">Attributes</a>
57+
{{sub_nav_attributes}}
58+
</li>
59+
5660
<li class="toctree-l1 {{current_layers}}">
5761
<a class="reference internal {{current_layers}}" href="layers.html">Map Layers</a>
5862
{{sub_nav_layers}}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<p>List the Java properties that can be set to configure Mapfish Print 3.</p>
2+
<p>
3+
The properties can be set using the <code>-D</code> option when starting the Java Virtual Machine. For
4+
example: by setting the <code>JAVA_OPTS</code> environment variable.
5+
</p>
6+
<ul>
7+
<li>
8+
<code>db.*</code> see the <a href="scaling.html#database_configuration">Database Configuration</a> section
9+
for details.
10+
</li>
11+
12+
<li>
13+
<code>mapfish.file.encoding</code>: the default character encoding used, the default is <code>UTF-8</code>
14+
</li>
15+
<li>
16+
<code>mapfish.maxContentLength</code>: the maximum size in bytes of HTTP request body specifications. The
17+
default is <code>10485760</code> (10 MB).
18+
</li>
19+
<li>
20+
<code>mapfish.image.plugins</code>: set to <code>true</code> to enable scanning for image plugins at
21+
startup (see
22+
<a
23+
href="https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/imageio/ImageIO.html#scanForPlugins()"
24+
>scanForPlugins</a
25+
>), used to enable WebP image format support. Default is <code>false</code>.
26+
</li>
27+
</ul>
2.86 KB
Loading
539 KB
Loading
3.43 KB
Loading

0 commit comments

Comments
 (0)