forked from pquiring/javaforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjimgconvert.java
More file actions
executable file
·42 lines (40 loc) · 1.29 KB
/
Copy pathjimgconvert.java
File metadata and controls
executable file
·42 lines (40 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package javaforce.utils;
import javaforce.*;
public class jimgconvert {
public static void main(String args[]) {
if (args.length != 2) {
System.out.println("Usage : jimgconvert filein fileout");
System.out.println("Suppports : jpg, png, bmp, ico(output only), icns(ouput only)");
return;
}
try {
JFImage img = new JFImage();
String infmt = args[0].substring(args[0].lastIndexOf(".")+1).toLowerCase();
if (infmt.equals("jpg")) {
img.loadJPG(args[0]);
} else if (infmt.equals("png")) {
img.loadPNG(args[0]);
} else if (infmt.equals("bmp")) {
img.loadBMP(args[0]);
} else {
throw new Exception("Unsupported input type:" + infmt);
}
String outfmt = args[1].substring(args[1].lastIndexOf(".")+1).toLowerCase();
if (outfmt.equals("jpg")) {
img.saveJPG(args[1]);
} else if (outfmt.equals("png")) {
img.savePNG(args[1]);
} else if (outfmt.equals("bmp")) {
img.saveBMP(args[1]);
} else if (outfmt.equals("ico")) {
img.saveICO(args[1]);
} else if (outfmt.equals("icns")) {
img.saveICNS(args[1]);
} else {
throw new Exception("Unsupported input type:" + infmt);
}
} catch (Exception e) {
JFLog.log(e);
}
}
};