How to use and build autotrace from source in Ubuntu 18.04

How to use and build autotrace from source in Ubuntu 18.04


 

 

AutoTrace is a utility for converting bitmap into vector graphics. AutoTrace can be compiled standalone, then it can import pnm, pbm, pgm, ppm, bmp and tga files. If you have installed libpng you can also read png files and with ImageMagick a very broad range of input formats is available.

In this article, we will explain you how to easily build autotrace in Ubuntu 18.04.

1. Install dependencies

In order to build the autotrace utility from scratch, you will need the following libraries installed on your system:

  • intltool: intltool is a set of tools to centralize translation of many different file formats using GNU gettext-compatible PO files.
  • imagemagick: ImageMagick, is a software suite to create, edit, and compose bitmap images. 
  • libmagickcore-dev: This package included header files and static libraries needed to compile programs using MagickCore.
  • pstoedit: pstoedit is a free computer program that converts PostScript and PDF files to other vector formats.
  • libpstoedit-dev: pstoedit is a framework for converting Postscript and PDF files to various editable vector graphic formats.
  • autopoint: The autopoint program is part of GNU gettext, a set of tools for translating programs into different languages.

You can install them easily in Ubuntu 18.04 with the following command:

sudo apt install intltool imagemagick libmagickcore-dev pstoedit libpstoedit-dev autopoint

Copy snippet

The installation of the mentioned packages will take ~240MB of space in your disk. Once you install the dependencies, we may proceed with the build of autotrace.

2. Clone autotrace source code

As next step, you will need to clone the source code of autotrace. You can directly obtain it with git running the following command in your terminal:

git clone https://github.com/autotrace/autotrace.git

Copy snippet

Once it has been cloned, change to the autotrace directory:

cd autotrace

Copy snippet

And proceed with the next step. For more information about the autotrace utility, please visit the official repository at Github here.

3. Generate the configure script

Now you will need to generate the configure script running the autogen file in the root directory of autotrace like this:

./autogen.sh

Copy snippet

Then specify that the autotrace content should be placed into /usr/{bin,lib,share,include} with the following command:

LD_LIBRARY_PATH=/usr/local/lib ./configure --prefix=/usr

Copy snippet

This should make autotrace accessible from the CLI once you build it.

4. Build and install

Finally, all you need to do is to run the make command on the directory:

make

Copy snippet

And then install the files in the proper directory with make install:

make install

Copy snippet

5. Using the autotrace CLI

All you have left after building and installing the tool is to test it. You can easily check the version of the built with the following command:

autotrace -v

Copy snippet

Which should output something similar to: AutoTrace version 0.40.0. The autotrace CLI options are defined like this:

 autotrace [-background-color  hexvalue] [-centerline] [-color-count  int] [-corner-always-
       threshold  angle] [-corner-surround  int] [-corner-threshold   angle]  [-despeckle-level
       int] [-despeckle-tightness  real] [-dpi  int] [-error-threshold  real] [-filter-iterations
        int] [-help] [-input-format  format] [-line-reversion-threshold  real] [-line-threshold
       real]  [-list-input-formats]  [-list-output-formats] [-log] [-output-file  file] [-output-
       format  format] [-preserve-width] [-remove-adjacent-corners]  [-report-progress]  [-debug-
       arch] [-debug-bitmap] [-tangent-surround  int] [-version] [-width-factor  real] inputfile

Copy snippet

The definition of what every options does is shown on the following list:

  • -background-color hexvalue: Employ  the  color specified by the hexadecimal code hexcode as the background that should be ignored, for example FFFFFF (default: no background color).
  • -centerline: Trace an object's centerline (default: employ its outline).
  • -color-count int: Reduce the bitmap to using the number of colors specified by the  unsigned  integer int (range: 1-256). The default value of 0 indicates that no color reduction is to be done.  Does not work with grayscale images.
  • -corner-always-threshold angle: Consider any angle at a pixel which falls below the specified angle (in degrees) as a corner, even if it is bordered by other corner pixels (default: 60).
  • -corner-surround int: Consider  the specified number of pixels on either side of a point when determining if that point is a corner (default: 4).
  • -corner-threshold angle: Consider any pixel which forms an angle with its  predecessor(s)  and  successor(s) that is smaller than the specified angle (in degrees) as a corner (default: 100).
  • -despeckle-level int: Employ  the  specified integer (range: 1-20) as the value for despeckling (default: no despeckling).
  • -despeckle-tightness real: Employ the specified real number  (range:  0.0-8.0)  as  the  value  for  despeckle tightness (default: 2.0).
  • -dpi int: The dots per inch value in the input image, affects scaling of mif output image.
  • -error-threshold real: Subdivide  fitted  curves  that  are  offset  by  a  number of pixels exceeding the specified real number (default: 2.0).
  • -filter-iterations int: Smooth the curve the specified number of times prior to fitting (default: 4).
  • -help: Print a help message and exit.
  • -input-format format: Employ the specified input format, where format is one of:
    • BMP (Windows bitmap format)
    • PBM (Portable BitMap format)
    • PGM (Portable Graymap format)
    • PNM (Portable Anymap format)
    • PPM (Portable Pixmap format)
    • TGA (Targa format)
    • The supported input formats are determined when the application is built and depend upon  the availability  of other software (the -list-input-formats command can be used to determine which are supported locally).
  • -line-reversion-threshold real: When a spline is closer to a straight line than the specified real number weighted by  the  square of the curve length (default: .01), maintain it as a straight line, even if it is a list with curves.
  • -line-threshold real: If a spline does not deviate from the straight line defined  by  its  endpoints  by more  than  the  specified  number  of  pixels,  then  treat  it as a straight line (default: 1).
  • -list-input-formats: Send a list of the supported input formats to stderr.
  • -list-output-formats: Send a list of the supported output formats to stderr.
  • -log: Send a detailed progress report to the file inputfile.log.
  • -output-file file: Send the output to the specified file.
  • -output-format format: Employ the specified output format, where format is one of:
    • ai(Adobe Illustrator)
    • cgm(Computer Graphics Metafile)
    • dr2d(IFF DR2D format, used almost exclusively on Amiga platforms)
    • dxf(AutoCAD Drawing Exchange format)
    • emf(Windows Enhanced Metafile format)
    • epd(Encapsulated Vectorial Graphics format)
    • eps(Encapsulated PostScript)
    • er(Elastic Reality Shape format)
    • fig(xfig (1) 3.2)
    • mif(FrameMaker MIF format)
    • pdf(Portable Data Format)
    • p2e(pstoedit (1) frontend)
    • sk(Sketch)
    • svg(Scalable Vector Graphics)
    • swf(Shockwave Flash 3)
    • The supported output formats are determined  when  the  application  is  built  and depend  upon  the  availability of other software (the -list-output-formats command can be used to determine which are supported locally).
  • -preserve-width: Whether to preserve line width prior to thinning.
  • -remove-adjacent-corners: Remove adjacent corners.
  • -report-progress: Report tracing status in real time.
  • -debug-arch: Print the type of cpu.
  • -debug-bitmap: Dump loaded bitmap to <input_name>.bitmap.\
  • -tangent-surround int: Consider the specified number of points to either side of a  point  when  computing the tangent at that point (default: 3).
  • -version: Print the version number of the program and exit.
  • -width-factor real: Weight factor for fitting the linewidth.

For example, in order to simply vectorize a BMP file, you may simply run the following command, replacing the input file path (bear.bmp) and the output file path (bear.svg):

autotrace -input-format bmp -output-format svg -output-file bear.svg bear.bmp

Copy snippet

Happy coding ❤️!

 

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值