source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java@ 13021

Last change on this file since 13021 was 13021, checked in by bastiK, 7 years ago

make Preferences more generic (see #15229, closes #15451)

  • extract base directories
  • move updateSystemProperties() as it is specific to JOSM-core as a "prefefences client"
File size: 26.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Dimension;
7import java.awt.image.BufferedImage;
8import java.io.File;
9import java.io.FileInputStream;
10import java.io.FileNotFoundException;
11import java.io.IOException;
12import java.util.ArrayList;
13import java.util.List;
14import java.util.Locale;
15import java.util.Optional;
16import java.util.function.Supplier;
17import java.util.logging.Level;
18
19import javax.imageio.ImageIO;
20
21import org.openstreetmap.gui.jmapviewer.OsmMercator;
22import org.openstreetmap.josm.CLIModule;
23import org.openstreetmap.josm.tools.I18n;
24import org.openstreetmap.josm.Main;
25import org.openstreetmap.josm.data.Bounds;
26import org.openstreetmap.josm.data.ProjectionBounds;
27import org.openstreetmap.josm.data.coor.EastNorth;
28import org.openstreetmap.josm.data.coor.LatLon;
29import org.openstreetmap.josm.data.coor.conversion.LatLonParser;
30import org.openstreetmap.josm.data.osm.DataSet;
31import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
32import org.openstreetmap.josm.data.projection.Projection;
33import org.openstreetmap.josm.data.projection.Projections;
34import org.openstreetmap.josm.gui.mappaint.RenderingHelper.StyleData;
35import org.openstreetmap.josm.io.IllegalDataException;
36import org.openstreetmap.josm.io.OsmReader;
37import org.openstreetmap.josm.spi.preferences.Config;
38import org.openstreetmap.josm.spi.preferences.MemoryPreferences;
39import org.openstreetmap.josm.tools.Logging;
40import org.openstreetmap.josm.tools.RightAndLefthandTraffic;
41
42import gnu.getopt.Getopt;
43import gnu.getopt.LongOpt;
44
45/**
46 * Command line interface for rendering osm data to an image file.
47 *
48 * @since 12906
49 */
50public class RenderingCLI implements CLIModule {
51
52 /**
53 * The singleton instance of this class.
54 */
55 public static final RenderingCLI INSTANCE = new RenderingCLI();
56
57 private static final double PIXEL_PER_METER = 96 / 2.54 * 100; // standard value of 96 dpi display resolution
58 private static final int DEFAULT_MAX_IMAGE_SIZE = 20000;
59
60 private boolean argDebug;
61 private boolean argTrace;
62 private String argInput;
63 private String argOutput;
64 private List<StyleData> argStyles;
65 private Integer argZoom;
66 private Double argScale;
67 private Bounds argBounds;
68 private LatLon argAnchor;
69 private Double argWidthM;
70 private Double argHeightM;
71 private Integer argWidthPx;
72 private Integer argHeightPx;
73 private String argProjection;
74 private Integer argMaxImageSize;
75
76 private enum Option {
77 HELP(false, 'h'),
78 DEBUG(false, '*'),
79 TRACE(false, '*'),
80 INPUT(true, 'i'),
81 STYLE(true, 's'),
82 SETTING(true, '*'),
83 OUTPUT(true, 'o'),
84 ZOOM(true, 'z'),
85 SCALE(true, '*'),
86 BOUNDS(true, 'b'),
87 ANCHOR(true, '*'),
88 WIDTH_M(true, '*'),
89 HEIGHT_M(true, '*'),
90 WIDTH_PX(true, '*'),
91 HEIGHT_PX(true, '*'),
92 PROJECTION(true, '*'),
93 MAX_IMAGE_SIZE(true, '*');
94
95 private final String name;
96 private final boolean requiresArg;
97 private final char shortOption;
98
99 Option(boolean requiresArgument, char shortOption) {
100 this.name = name().toLowerCase(Locale.US).replace('_', '-');
101 this.requiresArg = requiresArgument;
102 this.shortOption = shortOption;
103 }
104
105 /**
106 * Replies the option name
107 * @return The option name, in lowercase
108 */
109 public String getName() {
110 return name;
111 }
112
113 /**
114 * Determines if this option requires an argument.
115 * @return {@code true} if this option requires an argument, {@code false} otherwise
116 */
117 public boolean requiresArgument() {
118 return requiresArg;
119 }
120
121 /**
122 * Replies the short option (single letter) associated with this option.
123 * @return the short option or '*' if there is no short option
124 */
125 public char getShortOption() {
126 return shortOption;
127 }
128
129 LongOpt toLongOpt() {
130 return new LongOpt(getName(), requiresArgument() ? LongOpt.REQUIRED_ARGUMENT : LongOpt.NO_ARGUMENT, null, getShortOption());
131 }
132 }
133
134 /**
135 * Data class to hold return values for {@link #determineRenderingArea(DataSet)}.
136 *
137 * Package private access for unit tests.
138 */
139 static class RenderingArea {
140 public Bounds bounds;
141 public double scale; // in east-north units per pixel (unlike the --scale option, which is in meter per meter)
142 }
143
144 RenderingCLI() {
145 // hide constructor (package private access for unit tests)
146 }
147
148 @Override
149 public String getActionKeyword() {
150 return "render";
151 }
152
153 @Override
154 public void processArguments(String[] argArray) {
155 try {
156 parseArguments(argArray);
157 initialize();
158 DataSet ds = loadDataset();
159 RenderingArea area = determineRenderingArea(ds);
160 RenderingHelper rh = new RenderingHelper(ds, area.bounds, area.scale, argStyles);
161 checkPreconditions(rh);
162 BufferedImage image = rh.render();
163 writeImageToFile(image);
164 } catch (FileNotFoundException e) {
165 if (Logging.isDebugEnabled()) {
166 e.printStackTrace();
167 }
168 System.err.println(tr("Error - file not found: ''{0}''", e.getMessage()));
169 System.exit(1);
170 } catch (IllegalArgumentException | IllegalDataException | IOException e) {
171 if (Logging.isDebugEnabled()) {
172 e.printStackTrace();
173 }
174 if (e.getMessage() != null) {
175 System.err.println(tr("Error: {0}", e.getMessage()));
176 }
177 System.exit(1);
178 }
179 System.exit(0);
180 }
181
182 /**
183 * Parse command line arguments and do some low-level error checking.
184 * @param argArray the arguments array
185 */
186 void parseArguments(String[] argArray) {
187 Getopt.setI18nHandler(I18n::tr);
188 Logging.setLogLevel(Level.INFO);
189
190 LongOpt[] opts = new LongOpt[Option.values().length];
191 StringBuilder optString = new StringBuilder();
192 for (Option o : Option.values()) {
193 opts[o.ordinal()] = o.toLongOpt();
194 if (o.getShortOption() != '*') {
195 optString.append(o.getShortOption());
196 if (o.requiresArgument()) {
197 optString.append(':');
198 }
199 }
200 }
201
202 Getopt getopt = new Getopt("JOSM rendering", argArray, optString.toString(), opts);
203
204 StyleData currentStyle = new StyleData();
205 argStyles = new ArrayList<>();
206
207 int c;
208 while ((c = getopt.getopt()) != -1) {
209 switch (c) {
210 case 'h':
211 showHelp();
212 System.exit(0);
213 case 'i':
214 argInput = getopt.getOptarg();
215 break;
216 case 's':
217 if (currentStyle.styleUrl != null) {
218 argStyles.add(currentStyle);
219 currentStyle = new StyleData();
220 }
221 currentStyle.styleUrl = getopt.getOptarg();
222 break;
223 case 'o':
224 argOutput = getopt.getOptarg();
225 break;
226 case 'z':
227 try {
228 argZoom = Integer.parseInt(getopt.getOptarg());
229 } catch (NumberFormatException nfe) {
230 throw new IllegalArgumentException(
231 tr("Expected integer number for option {0}, but got ''{1}''", "--zoom", getopt.getOptarg()));
232 }
233 if (argZoom < 0)
234 throw new IllegalArgumentException(
235 tr("Expected integer number >= 0 for option {0}, but got ''{1}''", "--zoom", getopt.getOptarg()));
236 break;
237 case 'b':
238 if (!getopt.getOptarg().equals("auto")) {
239 try {
240 argBounds = new Bounds(getopt.getOptarg(), ",", Bounds.ParseMethod.LEFT_BOTTOM_RIGHT_TOP, false);
241 } catch (IllegalArgumentException iae) { // NOPMD
242 throw new IllegalArgumentException(tr("Unable to parse {0} parameter: {1}", "--bounds", iae.getMessage()));
243 }
244 }
245 break;
246 case '*':
247 switch (Option.values()[getopt.getLongind()]) {
248 case DEBUG:
249 argDebug = true;
250 break;
251 case TRACE:
252 argTrace = true;
253 break;
254 case SETTING:
255 String keyval = getopt.getOptarg();
256 String[] comp = keyval.split(":");
257 if (comp.length != 2)
258 throw new IllegalArgumentException(
259 tr("Expected key and value, separated by '':'' character for option {0}, but got ''{1}''",
260 "--setting", getopt.getOptarg()));
261 currentStyle.settings.put(comp[0].trim(), comp[1].trim());
262 break;
263 case SCALE:
264 try {
265 argScale = Double.parseDouble(getopt.getOptarg());
266 } catch (NumberFormatException nfe) {
267 throw new IllegalArgumentException(
268 tr("Expected floating point number for option {0}, but got ''{1}''", "--scale", getopt.getOptarg()));
269 }
270 break;
271 case ANCHOR:
272 String[] parts = getopt.getOptarg().split(",");
273 if (parts.length != 2)
274 throw new IllegalArgumentException(
275 tr("Expected two coordinates, separated by comma, for option {0}, but got ''{1}''",
276 "--anchor", getopt.getOptarg()));
277 try {
278 double lon = LatLonParser.parseCoordinate(parts[0]);
279 double lat = LatLonParser.parseCoordinate(parts[1]);
280 argAnchor = new LatLon(lat, lon);
281 } catch (IllegalArgumentException iae) { // NOPMD
282 throw new IllegalArgumentException(tr("In option {0}: {1}", "--anchor", iae.getMessage()));
283 }
284 break;
285 case WIDTH_M:
286 try {
287 argWidthM = Double.parseDouble(getopt.getOptarg());
288 } catch (NumberFormatException nfe) {
289 throw new IllegalArgumentException(
290 tr("Expected floating point number for option {0}, but got ''{1}''", "--width-m", getopt.getOptarg()));
291 }
292 if (argWidthM <= 0) throw new IllegalArgumentException(
293 tr("Expected floating point number > 0 for option {0}, but got ''{1}''", "--width-m", getopt.getOptarg()));
294 break;
295 case HEIGHT_M:
296 try {
297 argHeightM = Double.parseDouble(getopt.getOptarg());
298 } catch (NumberFormatException nfe) {
299 throw new IllegalArgumentException(
300 tr("Expected floating point number for option {0}, but got ''{1}''", "--height-m", getopt.getOptarg()));
301 }
302 if (argHeightM <= 0) throw new IllegalArgumentException(
303 tr("Expected floating point number > 0 for option {0}, but got ''{1}''", "--width-m", getopt.getOptarg()));
304 break;
305 case WIDTH_PX:
306 try {
307 argWidthPx = Integer.parseInt(getopt.getOptarg());
308 } catch (NumberFormatException nfe) {
309 throw new IllegalArgumentException(
310 tr("Expected integer number for option {0}, but got ''{1}''", "--width-px", getopt.getOptarg()));
311 }
312 if (argWidthPx <= 0) throw new IllegalArgumentException(
313 tr("Expected integer number > 0 for option {0}, but got ''{1}''", "--width-px", getopt.getOptarg()));
314 break;
315 case HEIGHT_PX:
316 try {
317 argHeightPx = Integer.parseInt(getopt.getOptarg());
318 } catch (NumberFormatException nfe) {
319 throw new IllegalArgumentException(
320 tr("Expected integer number for option {0}, but got ''{1}''", "--height-px", getopt.getOptarg()));
321 }
322 if (argHeightPx <= 0) throw new IllegalArgumentException(
323 tr("Expected integer number > 0 for option {0}, but got ''{1}''", "--height-px", getopt.getOptarg()));
324 break;
325 case PROJECTION:
326 argProjection = getopt.getOptarg();
327 break;
328 case MAX_IMAGE_SIZE:
329 try {
330 argMaxImageSize = Integer.parseInt(getopt.getOptarg());
331 } catch (NumberFormatException nfe) {
332 throw new IllegalArgumentException(
333 tr("Expected integer number for option {0}, but got ''{1}''", "--max-image-size", getopt.getOptarg()));
334 }
335 if (argMaxImageSize < 0) throw new IllegalArgumentException(
336 tr("Expected integer number >= 0 for option {0}, but got ''{1}''", "--max-image-size", getopt.getOptarg()));
337 break;
338 default:
339 throw new AssertionError("Unexpected option index: " + getopt.getLongind());
340 }
341 break;
342 case '?':
343 throw new IllegalArgumentException(); // getopt error
344 default:
345 throw new AssertionError("Unrecognized option: " + c);
346 }
347 }
348 if (currentStyle.styleUrl != null) {
349 argStyles.add(currentStyle);
350 }
351 }
352
353 /**
354 * Displays help on the console
355 */
356 public static void showHelp() {
357 System.out.println(getHelp());
358 }
359
360 private static String getHelp() {
361 return tr("JOSM rendering command line interface")+"\n\n"+
362 tr("Usage")+":\n"+
363 "\tjava -jar josm.jar render <options>\n\n"+
364 tr("Description")+":\n"+
365 tr("Renders data and saves the result to an image file.")+"\n\n"+
366 tr("Options")+":\n"+
367 "\t--help|-h "+tr("Show this help")+"\n"+
368 "\t--input|-i <file> "+tr("Input data file name (.osm)")+"\n"+
369 "\t--output|-o <file> "+tr("Output image file name (.png); defaults to ''{0}''", "out.png")+"\n"+
370 "\t--style|-s <file> "+tr("Style file to use for rendering (.mapcss or .zip)")+"\n"+
371 "\t "+tr("This option can be repeated to load multiple styles.")+"\n"+
372 "\t--setting <key>:<value> "+tr("Style setting (in JOSM accessible in the style list dialog right click menu)")+"\n"+
373 "\t "+tr("Applies to the last style loaded with the {0} option.", "--style")+"\n"+
374 "\t--zoom|-z <lvl> "+tr("Select zoom level to render. (integer value, 0=entire earth, 18=street level)")+"\n"+
375 "\t--scale <scale> "+tr("Select the map scale")+"\n"+
376 "\t "+tr("A value of 10000 denotes a scale of 1:10000 (1 cm on the map equals 100 m on the ground; "
377 + "display resolution: 96 dpi)")+"\n"+
378 "\t "+tr("Options {0} and {1} are mutually exclusive.", "--zoom", "--scale")+"\n"+
379 "\t--bounds|-b auto|<min_lon>,<min_lat>,<max_lon>,<max_lat>\n"+
380 "\t "+tr("Area to render, default value is ''{0}''", "auto")+"\n"+
381 "\t "+tr("With keyword ''{0}'', the downloaded area in the .osm input file will be used (if recorded).",
382 "auto")+"\n"+
383 "\t--anchor <lon>,<lat> "+tr("Specify bottom left corner of the rendering area")+"\n"+
384 "\t "+tr("Used in combination with width and height options to determine the area to render.")+"\n"+
385 "\t--width-m <number> "+tr("Width of the rendered area, in meter")+"\n"+
386 "\t--height-m <number> "+tr("Height of the rendered area, in meter")+"\n"+
387 "\t--width-px <number> "+tr("Width of the target image, in pixel")+"\n"+
388 "\t--height-px <number> "+tr("Height of the target image, in pixel")+"\n"+
389 "\t--projection <code> "+tr("Projection to use, default value ''{0}'' (web-Mercator)", "epsg:3857")+"\n"+
390 "\t--max-image-size <number> "+tr("Maximum image width/height in pixel (''{0}'' means no limit), default value: {1}",
391 0, Integer.toString(DEFAULT_MAX_IMAGE_SIZE))+"\n"+
392 "\n"+
393 tr("To specify the rendered area and scale, the options can be combined in various ways")+":\n"+
394 " * --bounds (--zoom|--scale|--width-px|--height-px)\n"+
395 " * --anchor (--width-m|--width-px) (--height-m|--height-px) (--zoom|--scale)\n"+
396 " * --anchor --width-m --height-m (--width-px|--height-px)\n"+
397 " * --anchor --width-px --height-px (--width-m|--height-m)\n"+
398 tr("If neither ''{0}'' nor ''{1}'' is given, the default value {2} takes effect "
399 + "and the bounds of the download area in the .osm input file are used.",
400 "bounds", "anchor", "--bounds=auto")+"\n\n"+
401 tr("Examples")+":\n"+
402 " java -jar josm.jar render -i data.osm -s style.mapcss -z 16\n"+
403 " josm render -i data.osm -s style.mapcss --scale 5000\n"+
404 " josm render -i data.osm -s style.mapcss -z 16 -o image.png\n"+
405 " josm render -i data.osm -s elemstyles.mapcss --setting hide_icons:false -z 16\n"+
406 " josm render -i data.osm -s style.mapcss -s another_style.mapcss -z 16 -o image.png\n"+
407 " josm render -i data.osm -s style.mapcss --bounds 21.151,51.401,21.152,51.402 -z 16\n"+
408 " josm render -i data.osm -s style.mapcss --anchor 21.151,51.401 --width-m 500 --height-m 300 -z 16\n"+
409 " josm render -i data.osm -s style.mapcss --anchor 21.151,51.401 --width-m 500 --height-m 300 --width-px 1800\n"+
410 " josm render -i data.osm -s style.mapcss --scale 5000 --projection epsg:4326\n";
411 }
412
413 /**
414 * Initialization.
415 *
416 * Requires arguments to be parsed already ({@link #parseArguments(java.lang.String[])}).
417 */
418 void initialize() {
419 Logging.setLogLevel(getLogLevel());
420
421 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); // for right-left-hand traffic cache file
422 Config.setPreferencesInstance(new MemoryPreferences());
423 Config.getPref().putBoolean("mappaint.auto_reload_local_styles", false); // unnecessary to listen for external changes
424 String projCode = Optional.ofNullable(argProjection).orElse("epsg:3857");
425 Main.setProjection(Projections.getProjectionByCode(projCode.toUpperCase(Locale.US)));
426
427 RightAndLefthandTraffic.initialize();
428 }
429
430 private Level getLogLevel() {
431 if (argTrace) {
432 return Logging.LEVEL_TRACE;
433 } else if (argDebug) {
434 return Logging.LEVEL_DEBUG;
435 } else {
436 return Logging.LEVEL_INFO;
437 }
438 }
439
440 /**
441 * Find the area to render and the scale, given certain command line options and the dataset.
442 * @param ds the dataset
443 * @return area to render and the scale
444 */
445 RenderingArea determineRenderingArea(DataSet ds) {
446
447 Projection proj = Main.getProjection();
448 Double scale = null; // scale in east-north units per pixel
449 if (argZoom != null) {
450 scale = OsmMercator.EARTH_RADIUS * Math.PI * 2 / Math.pow(2, argZoom) / OsmMercator.DEFAUL_TILE_SIZE / proj.getMetersPerUnit();
451 }
452 Bounds bounds = argBounds;
453 ProjectionBounds pb = null;
454
455 if (bounds == null) {
456 if (argAnchor != null) {
457 EastNorth projAnchor = proj.latlon2eastNorth(argAnchor);
458
459 Double enPerMeter = null;
460 Supplier<Double> getEnPerMeter = () -> {
461 double shiftMeter = 10;
462 EastNorth projAnchorShifted = projAnchor.add(
463 shiftMeter / proj.getMetersPerUnit(), shiftMeter / proj.getMetersPerUnit());
464 LatLon anchorShifted = proj.eastNorth2latlon(projAnchorShifted);
465 return projAnchor.distance(projAnchorShifted) / argAnchor.greatCircleDistance(anchorShifted);
466 };
467
468 if (scale == null) {
469 if (argScale != null) {
470 enPerMeter = getEnPerMeter.get();
471 scale = argScale * enPerMeter / PIXEL_PER_METER;
472 } else if (argWidthM != null && argWidthPx != null) {
473 enPerMeter = getEnPerMeter.get();
474 scale = argWidthM / argWidthPx * enPerMeter;
475 } else if (argHeightM != null && argHeightPx != null) {
476 enPerMeter = getEnPerMeter.get();
477 scale = argHeightM / argHeightPx * enPerMeter;
478 } else {
479 throw new IllegalArgumentException(
480 tr("Argument {0} given, but scale cannot be determined from remaining arguments", "--anchor"));
481 }
482 }
483
484 double widthEn;
485 if (argWidthM != null) {
486 enPerMeter = Optional.ofNullable(enPerMeter).orElseGet(getEnPerMeter);
487 widthEn = argWidthM * enPerMeter;
488 } else if (argWidthPx != null) {
489 widthEn = argWidthPx * scale;
490 } else {
491 throw new IllegalArgumentException(
492 tr("Argument {0} given, expected {1} or {2}", "--anchor", "--width-m", "--width-px"));
493 }
494
495 double heightEn;
496 if (argHeightM != null) {
497 enPerMeter = Optional.ofNullable(enPerMeter).orElseGet(getEnPerMeter);
498 heightEn = argHeightM * enPerMeter;
499 } else if (argHeightPx != null) {
500 heightEn = argHeightPx * scale;
501 } else {
502 throw new IllegalArgumentException(
503 tr("Argument {0} given, expected {1} or {2}", "--anchor", "--height-m", "--height-px"));
504 }
505 pb = new ProjectionBounds(projAnchor);
506 pb.extend(new EastNorth(projAnchor.east() + widthEn, projAnchor.north() + heightEn));
507 bounds = new Bounds(proj.eastNorth2latlon(pb.getMin()), false);
508 bounds.extend(proj.eastNorth2latlon(pb.getMax()));
509 } else {
510 if (ds.getDataSourceBounds().isEmpty()) {
511 throw new IllegalArgumentException(tr("{0} mode, but no bounds found in osm data input file", "--bounds=auto"));
512 }
513 bounds = ds.getDataSourceBounds().get(0);
514 }
515 }
516
517 if (pb == null) {
518 pb = new ProjectionBounds();
519 pb.extend(proj.latlon2eastNorth(bounds.getMin()));
520 pb.extend(proj.latlon2eastNorth(bounds.getMax()));
521 }
522
523 if (scale == null) {
524 if (argScale != null) {
525 double enPerMeter = pb.getMin().distance(pb.getMax()) / bounds.getMin().greatCircleDistance(bounds.getMax());
526 scale = argScale * enPerMeter / PIXEL_PER_METER;
527 } else if (argWidthPx != null) {
528 scale = (pb.maxEast - pb.minEast) / argWidthPx;
529 } else if (argHeightPx != null) {
530 scale = (pb.maxNorth - pb.minNorth) / argHeightPx;
531 } else {
532 throw new IllegalArgumentException(
533 tr("Unable to determine scale, one of the options {0}, {1}, {2} or {3} expected",
534 "--zoom", "--scale", "--width-px", "--height-px"));
535 }
536 }
537
538 RenderingArea ra = new RenderingArea();
539 ra.bounds = bounds;
540 ra.scale = scale;
541 return ra;
542 }
543
544 private DataSet loadDataset() throws FileNotFoundException, IllegalDataException {
545 if (argInput == null) {
546 throw new IllegalArgumentException(tr("Missing argument - input data file ({0})", "--input|-i"));
547 }
548 try {
549 return OsmReader.parseDataSet(new FileInputStream(argInput), null);
550 } catch (IllegalDataException e) {
551 throw new IllegalDataException(tr("In .osm data file ''{0}'' - ", argInput) + e.getMessage());
552 }
553 }
554
555 private void checkPreconditions(RenderingHelper rh) {
556 if (argStyles.isEmpty())
557 throw new IllegalArgumentException(tr("Missing argument - at least one style expected ({0})", "--style"));
558
559 Dimension imgSize = rh.getImageSize();
560 Logging.debug("image size (px): {0}x{1}", imgSize.width, imgSize.height);
561 int maxSize = Optional.ofNullable(argMaxImageSize).orElse(DEFAULT_MAX_IMAGE_SIZE);
562 if (maxSize != 0 && (imgSize.width > maxSize || imgSize.height > maxSize)) {
563 throw new IllegalArgumentException(
564 tr("Image dimensions ({0}x{1}) exceeds maximum image size {2} (use option {3} to change limit)",
565 imgSize.width, imgSize.height, maxSize, "--max-image-size"));
566 }
567 }
568
569 private void writeImageToFile(BufferedImage image) throws IOException {
570 String output = Optional.ofNullable(argOutput).orElse("out.png");
571 ImageIO.write(image, "png", new File(output));
572 }
573}
Note: See TracBrowser for help on using the repository browser.