1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,39 @@ |
1 |
+#!/usr/bin/pike |
|
2 |
+/* |
|
3 |
+ * png2jpg.pike |
|
4 |
+ * |
|
5 |
+ * Saves the specifyed file as jpg |
|
6 |
+ * |
|
7 |
+ * History: |
|
8 |
+ * 14/01/2024 Creation |
|
9 |
+ * |
|
10 |
+ * Author: Dario Rodriguez antartica@whereismybit.com |
|
11 |
+ * This program is distributed under the terms of the GNU GPL v2.1+ |
|
12 |
+ */ |
|
13 |
+ |
|
14 |
+int |
|
15 |
+main(int argc, array(string) argv) |
|
16 |
+{ |
|
17 |
+ string destfilename; |
|
18 |
+ string infilename; |
|
19 |
+ int quality; |
|
20 |
+ Image.Image image; |
|
21 |
+ if(!(argc==3 || (argc==5 && argv[1]=="-q")) || (argc>1 && argv[1]=="--help")) { |
|
22 |
+ Stdio.werror("Syntax: "+argv[0]+" [-q <jpgquality>] <origfile.png> <destfile.png>\n"); |
|
23 |
+ Stdio.werror("Example: "+argv[0]+" file.png dest.jpg\n"); |
|
24 |
+ Stdio.werror("Example result: dest.jpg\n"); |
|
25 |
+ return(1); |
|
26 |
+ } |
|
27 |
+ quality=95; |
|
28 |
+ if(argc==5 && argv[1]=="-q") |
|
29 |
+ quality=(int)argv[2]; |
|
30 |
+ destfilename=argv[sizeof(argv)-1]; |
|
31 |
+ infilename=argv[sizeof(argv)-2]; |
|
32 |
+ write("* Loading image\n"); |
|
33 |
+ image=Image.load(infilename); |
|
34 |
+ write("* Writing "+destfilename+"...\n"); |
|
35 |
+ Stdio.write_file(destfilename,Image.JPEG.encode(image,(["quality":quality]))); |
|
36 |
+ write("Converted image to "+destfilename+". Process finished.\n"); |
|
37 |
+ return(0); |
|
38 |
+} |
|
39 |
+ |