Tag Archives: Trivial problems

Converting PDF file to JPG image in Ubuntu

>

sudo apt-get install imagemagick

ImageMagick
(Use image instead of the specific file name.)
With the convert image. PDF image. JPG can translate directly, but the image resolution is not high
with the following command transformation effect is better

convert -verbose -colorspace RGB -resize 1800 -interlace none -density 300 -quality 100 image.pdf image.jpg

(-Resize the following coefficient to adjust the width of the image in pixels, and the height to scale)
If the following error occurs

convert: not authorized `grade.pdf' @ error/constitute.c/ReadImage/412.
convert: no images defined `*.jpg' @ error/convert.c/ConvertImageCommand/3210.

Because the ImageMagick policy. XML file does not give "read and write PDF files" permission by default.
Open the policy-.xml file

sudo vi /etc/ImageMagick-6/policy.xml

< policy domain="coder" rights="none" pattern="PDF" /> in the "none" instead "read/write"
In addition, a few simple features of ImageMagick are also posted below
Pictures are made into GIFs

convert *.jpg images.gif

Where * is the wildcard, *. JPG means all the path under the JPG file
in addition to the image format in JPG, can also be PNG and other common image format
Modify image size
Take a single picture for example

convert 'image.jpg' -resize 1200 image2.jpg

(1200 means that the width becomes 1200 pixels, and the height varies proportionally)
Take several pictures for example

convert '*.jpg' -resize 1200 %03d.jpg

(can also be converted to other image format)
(% 3 d. The JPG said to give the picture of the new generation in 000. The JPG, 001 JPG rule named)
(if written image % 3 d. The JPG, said to a new generation of picture by image000. The JPG, image001. The law of the JPG)
This can also be written:

convert '*.jpg[1200]' %03d.jpg