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).

!7

lib 1013691 // batik
lib 1013693 // batik svg
lib 1013694 

import org.apache.batik.transcoder.image.PNGTranscoder;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;

p-experiment {
  inputFilePath("Directory", voidfunc(File dir) {
    for (File svg : listFilesWithExtension(dir, "svg")) {
      print(svg);
      TranscoderInput input_svg_image = new TranscoderInput(fileToURI(svg));
      
      File file;
      OutputStream png_ostream = newFileOutputStream(file = getProgramFile(dropSuffix(".svg", svg.getName()) + ".png"));
      TranscoderOutput output_png_image = new TranscoderOutput(png_ostream);
      
      new PNGTranscoder t;
      int w = loadImage2(getProgramFile(programID(), "original size/" + file.getName())).getWidth();
      t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, (float) (w*4));
      t.transcode(input_svg_image, output_png_image);
      
      png_ostream.close();
    }
  });
}

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: 493 / 1463
Version history: 12 change(s)
Referenced in: [show references]