Convert the PNG image that appears during latex compilation to the EPS format

Source: Internet
Author: User
Tags imagemagick

When I was writing my graduation thesis recently, I used latex for writing. One of the problems was that many of the general films existed. Many PNG images can only be compiled using pdflatex, however, after the compiled Chinese characters are copied out, they are garbled and very troublesome. Therefore, latex is used for compilation. However, the default image must be an EPS or PDF image. You can find a solution on the Internet, quickly convert a PNG Image to an EPS format. For specific solutions, see the link:

Http://cherishlc.iteye.com/blog/1727490

When writing latex, it is often necessary to convert PNG and jpg files into EPS files. It is very troublesome to use Photoshop or Matlab every time, and it is found that ImageMagick is not bad ~
1. Download
Download and install the SDK at the following URL.
Http://www.imagemagick.org/script/binary-releases.php#windows
Supported file formats: http://www.imagemagick.org/script/formats.php

2. Processing of EPS files
It is said that ghostscript needs to be installed, not tested, and ghostscript is included in ctex anyway.

3. Written batch files
The following code is used to convert the jpg and PNG files in the current directory to the EPS files. Note that the files are eps3 files. It is said that the files are relatively small after conversion. Actually, the files are relatively small. The comparison between K and 30 m !!! Compatibility is unknown... It's okay if I use ctex.
The image size is set to height or the width must be less than 1600 pixels (the value can be set as needed, otherwise the large image is not displayed completely !!)

CMD code
  1. For % I in (*. jpg) Do convert-resize "1600x1600>" % I eps3: % ~ Ni. EPS
  2. For % I in (*. PNG) Do convert-resize "1600x1600>" % I eps3: % ~ Ni. EPS



4. options related to the output image size
See http://www.imagemagick.org/script/command-line-processing.php#geometry
In addition to the following options, it seems that the-page option is also useful and has not been tested.




Appendix: Reference and reprinted

More useful convert options:
Reprinted from: http://blog.sina.com.cn/s/blog_44a0dd4c0100cqq8.html
Convert.exe
Simplest usage: convert.exe aaa.jpg aaa.png
Parameters that may be used (I will not explain them if they are useless, but there are too many parameters ):
-Layers flatten: it is used to merge multiple layers into one layer when converting the PSD file. Otherwise, multiple PSD images will appear when converting multiple layers, each of which corresponds to one layer.
Example: convert.exe-layers flatten AAA. PSD aaa.jpg
-Density 72: Specifies the resolution of the image, that is, the number of pixels per unit area. If you do not know this, it is incorrect. The default unit is inch.
-Units pixelsperinch: Specifies the Unit. This parameter is used with-density to specify the unit of-density. This is very important. I found that the resolution unit of some images is centimeter, the two units are far behind each other.
Example: convert.exe-density 72-units pixelsperinch AAA. tif aaa.jpg
-Resize 1024x768: Specifies the image conversion size. Im will automatically determine the width and height of the image for proportional compression. But there is a problem, that is, when the image is smaller than x768, the image will be forcibly zoomed in. You can add delimiters such as '>' and '<' After x768 to restrict conversion behavior. 1024x768> only converts a graph larger than 1024x768 <only converts a graph smaller than X. For other delimiters, see the manual.
Example: convert.exe-resize "1024x768>" AAA. tif aaa.jpg
Note: 1024x768> must be enclosed in quotation marks. Otherwise, '>' is interpreted as output redirection.
-Filter Lanczos: Specifies the filter used to convert an image. It is usually used with-resize. There are many kinds of filters. After one try, I think this is suitable and others do not understand it.
-Quality 100: Specifies the JPEG image quality compression ratio. The default value is 80%. Here we specify 100%, which is the best quality.
-Colorspace RGB: Specifies the color space of the converted image. There is a lot of color space, and the use of RGB on the PC is sufficient.
+ Profile "*": deletes metadata information attached to an image, including EXIF. This data occupies a lot of space, so you can directly delete it.

Idenpolicy.exe
This tool is used to view image details, including color space and layer information.
For more information about the image, use: identify.exe-verbose aaa.jpg.

With the above parameters, everything can be done. However, to enable ImageMagick to process the image files of the EPS, you also need to install another software package, ghostscript, which is specially used to process the PS files. You can search and download it.




On eps3 option usage Reprinted from: http://blog.sciencenet.cn/home.php? MoD = Space & uid = 47991 & Do = Blog & id = 535301
Reference convert fig.png eps3: fig. EPS
Here, eps3 uses Level 3, and level refers to the compatibility level adopted by postscript. Level 1 has the worst effect and the file size is large. Level 2 supports generating an EPS file from JPG, and the file size is small. Level 3 supports zlib compression, and can also generate an EPS file from PNG. Generally speaking, Level 3 produces the least file and level 2 has the best compatibility.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.