Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1014597 // Convert .svg to .png (quick hack)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 7750K of libraries. Click here for Pure Java version (7565L/51K).

1  
!7
2  
3  
lib 1013691 // batik
4  
lib 1013693 // batik svg
5  
lib 1013694 
6  
7  
import org.apache.batik.transcoder.image.PNGTranscoder;
8  
import org.apache.batik.transcoder.TranscoderInput;
9  
import org.apache.batik.transcoder.TranscoderOutput;
10  
11  
p-experiment {
12  
  inputFilePath("Directory", voidfunc(File dir) {
13  
    for (File svg : listFilesWithExtension(dir, "svg")) {
14  
      print(svg);
15  
      TranscoderInput input_svg_image = new TranscoderInput(fileToURI(svg));
16  
      
17  
      File file;
18  
      OutputStream png_ostream = newFileOutputStream(file = getProgramFile(dropSuffix(".svg", svg.getName()) + ".png"));
19  
      TranscoderOutput output_png_image = new TranscoderOutput(png_ostream);
20  
      
21  
      new PNGTranscoder t;
22  
      int w = loadImage2(getProgramFile(programID(), "original size/" + file.getName())).getWidth();
23  
      t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, (float) (w*4));
24  
      t.transcode(input_svg_image, output_png_image);
25  
      
26  
      png_ostream.close();
27  
    }
28  
  });
29  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014597
Snippet name: Convert .svg to .png (quick hack)
Eternal ID of this version: #1014597/13
Text MD5: 145bbcbab842e4b3bda639d80033c183
Transpilation MD5: 10792daf913b72a0e3db8266cdeb5629
Author: stefan
Category: javax / images
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-26 00:22:10
Source code size: 998 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 312 / 1043
Version history: 12 change(s)
Referenced in: [show references]