[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

30元求potrace批转换命令行

本帖最后由 玉说还休 于 2019-4-11 22:03 编辑

potrace是个位图转矢量的一个程序。现在需要一个win下的转换命令,能帮我做成bat最好。
支付方式:微信红包

Linux下批量转换png为svg的脚本
#!/bin/bash

File_png="${1?:Usage: $0 file.png}"

if [[ ! -s "$File_png" ]]; then
  echo >&2 "The first argument ($File_png)"
  echo >&2 "must be a file having a size greater than zero"
  ( set -x ; ls -s "$File_png" )
  exit 1
fi

File="${File_png%.*}"

convert "$File_png" "$File.pnm"        # PNG to PNM
potrace "$File.pnm" -s -o "$File.svg"  # PNM to SVG
rm "$File.pnm"                         # Remove PNM

https://www.orcode.com/question/418130_k1d372.html



potrace 1.15. Transforms bitmaps into vector graphics.

Usage: potrace [options] [filename...]
General options:
-h, --help                 - print this help message and exit
-v, --version              - print version info and exit
-l, --license              - print license info and exit
File selection:
filename                   - an input file
-o, --output filename      - write all output to this file
--                         - end of options; 0 or more input filenames follow
Backend selection:
-b, --backend name         - select backend by name
-b svg, -s, --svg          - SVG backend (scalable vector graphics)
-b pdf                     - PDF backend (portable document format)
-b pdfpage                 - fixed page-size PDF backend
-b eps, -e, --eps          - EPS backend (encapsulated PostScript) (default)
-b ps, -p, --postscript    - PostScript backend
-b pgm, -g, --pgm          - PGM backend (portable greymap)
-b dxf                     - DXF backend (drawing interchange format)
-b geojson                 - GeoJSON backend
-b gimppath                - Gimppath backend (GNU Gimp)
-b xfig                    - XFig backend
Algorithm options:
-z, --turnpolicy policy    - how to resolve ambiguities in path decomposition
-t, --turdsize n           - suppress speckles of up to this size (default 2)
-a, --alphamax n           - corner threshold parameter (default 1)
-n, --longcurve            - turn off curve optimization
-O, --opttolerance n       - curve optimization tolerance (default 0.2)
-u, --unit n               - quantize output to 1/unit pixels (default 10)
-d, --debug n              - produce debugging output of type n (n=1,2,3)
Scaling and placement options:
-P, --pagesize format      - page size (default is letter)
-W, --width dim            - width of output image
-H, --height dim           - height of output image
-r, --resolution n[xn]     - resolution (in dpi) (dimension-based backends)
-x, --scale n[xn]          - scaling factor (pixel-based backends)
-S, --stretch n            - yresolution/xresolution
-A, --rotate angle         - rotate counterclockwise by angle
-M, --margin dim           - margin
-L, --leftmargin dim       - left margin
-R, --rightmargin dim      - right margin
-T, --topmargin dim        - top margin
-B, --bottommargin dim     - bottom margin
--tight                    - remove whitespace around the input image
Color options, supported by some backends:
-C, --color #rrggbb        - set foreground color (default black)
--fillcolor #rrggbb        - set fill color (default transparent)
--opaque                   - make white shapes opaque
SVG options:
--group                    - group related paths together
--flat                     - whole image as a single path
Postscript/EPS/PDF options:
-c, --cleartext            - do not compress the output
-2, --level2               - use postscript level 2 compression (default)
-3, --level3               - use postscript level 3 compression
-q, --longcoding           - do not optimize for file size
PGM options:
-G, --gamma n              - gamma value for anti-aliasing (default 2.2)
Frontend options:
-k, --blacklevel n         - black/white cutoff in input file (default 0.5)
-i, --invert               - invert bitmap
Progress bar options:
--progress                 - show progress bar
--tty mode                 - progress bar rendering: vt100 or dumb

Dimensions can have optional units, e.g. 6.5in, 15cm, 100pt.
Default is inches (or pixels for pgm, dxf, and gimppath backends).
Possible input file formats are: pnm (pbm, pgm, ppm), bmp.
Backends are: svg, pdf, pdfpage, eps, postscript, ps, dxf, geojson, pgm,
gimppath, xfig.

回复  玉说还休
Batcher 发表于 2019-4-11 22:23



    多谢Batcher大,由于zaqmlp大先一步提供方案,我就选zaqmlp大的解决方案了,多谢辛苦帮助解决。

TOP

回复 4# zaqmlp


    多谢zaqmlp大大,已完美解决。

TOP

回复 3# 玉说还休
  1. @echo off
  2. cd /d "C:\QG"
  3. for /f "delims=" %%i in ('dir /b /a-d *.bmp') do (
  4.     potrace -s -q "%%i"
  5. )
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

  1. @echo off
  2. set info=互助互利,支付宝扫码头像,感谢赞助
  3. rem 有问题,可加QQ956535081及时沟通
  4. rem 把convert.exe、potrace.exe跟bat放一起
  5. title %info%
  6. start mshta VBScript:Execute("msgbox(""%info%""):close")
  7. cd /d "%~dp0"
  8. for /f "delims=" %%a in ('dir /a-d/b/s *.png') do (
  9.     convert.exe "%%a" "%%~dpna.pnm"
  10.     potrace.exe "%%~dpna.pnm" -s -o "%%~dpna.svg"
  11.     del "%%~dpna.pnm"
  12. )
  13. pause
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 2# Batcher

就是,现在我可以把单张转换,如:potrace -s -q C:\QG\45.bmp  这样就能转换出一张,但是一个文件夹里比如有好几千张,我就得重复这么做几千次,好累啊。所以如果有个简单的方法可以自动处理就好

TOP

http://potrace.sourceforge.net/#downloading
这不是有Windows版本的吗,你想做成什么效果?
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

返回列表