You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2001/03/01 02:20:53 UTC
cvs commit: xml-batik/sources/org/apache/batik/apps/rasterizer Main.java
vhardy 01/02/28 17:20:53
Modified: sources/org/apache/batik/apps/rasterizer Main.java
Log:
Added -w (width) and -h (height) parameters.
Revision Changes Path
1.7 +47 -1 xml-batik/sources/org/apache/batik/apps/rasterizer/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/rasterizer/Main.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Main.java 2001/01/31 04:18:16 1.6
+++ Main.java 2001/03/01 01:20:52 1.7
@@ -30,7 +30,7 @@
* A simple class that can generate images from svg documents.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: Main.java,v 1.6 2001/01/31 04:18:16 tkormann Exp $
+ * @version $Id: Main.java,v 1.7 2001/03/01 01:20:52 vhardy Exp $
*/
public class Main {
@@ -57,6 +57,8 @@
out.println("usage: rasterizer [options] [@files]");
out.println("-d <directory> Destination directory for output files");
out.println("-m <mimetype> Mime type for output files");
+ out.println("-w <width> Width of the output image");
+ out.println("-h <height> Height of the output image");
}
public static void main(String [] args) {
@@ -64,6 +66,9 @@
String directory = null;
List svgFiles = new LinkedList();
int i=0;
+ float width = Float.NaN;
+ float height = Float.NaN;
+
while (i < args.length) {
if (args[i].equals("-d")) {
if (i+1 < args.length) {
@@ -85,6 +90,36 @@
usage(System.err);
System.exit(1);
}
+ } else if (args[i].equals("-w")) {
+ if (i+1 < args.length) {
+ i++;
+ try{
+ width = Float.parseFloat(args[i++]);
+ }catch(NumberFormatException e){
+ usage(System.err);
+ System.exit(1);
+ }
+ continue;
+ } else {
+ error("option -w requires an argument");
+ usage(System.err);
+ System.exit(1);
+ }
+ } else if (args[i].equals("-h")) {
+ if (i+1 < args.length) {
+ i++;
+ try{
+ width = Float.parseFloat(args[i++]);
+ }catch(NumberFormatException e){
+ usage(System.err);
+ System.exit(1);
+ }
+ continue;
+ } else {
+ error("option -h requires an argument");
+ usage(System.err);
+ System.exit(1);
+ }
} else if (args[i].equals("-help")) {
usage(System.out);
System.exit(0);
@@ -112,6 +147,17 @@
error("No transcoder found for mime type : "+mimeType);
System.exit(1);
}
+
+ if(!Float.isNaN(width)){
+ t.addTranscodingHint(ImageTranscoder.KEY_WIDTH,
+ new Float(width));
+ }
+
+ if(!Float.isNaN(height)){
+ t.addTranscodingHint(ImageTranscoder.KEY_HEIGHT,
+ new Float(height));
+ }
+
for (Iterator iter = svgFiles.iterator(); iter.hasNext();) {
String s = (String) iter.next();
File f = new File(s);