Showing posts with label jpg. Show all posts
Showing posts with label jpg. Show all posts

Sunday, October 14, 2018

imagemagick / convert error when converting a group of jpgs to a pdf. introduced as an inconvenience / bug


The latest set of security updates on Ubuntu seems to have jacked up the imagemagick settings.

Have to do the change suggested in the following tip from Ubuntu questions.

https://askubuntu.com/questions/1081695/error-during-converting-jpg-to-pdf

Problem:

Each time I want to convert jpg file to pdf by this command
convert *.jpg pictures.pdf
I have this error message:
convert: not authorized `pictures.pdf' @ error/constitute.c/WriteImage/1028.
 
Solution as of Oct 7 2018
 
This problems comes from a security update: https://launchpad.net/ubuntu/+source/imagemagick/8:6.8.9.9-7ubuntu5.13
Someone reported it as a bug: https://bugs.launchpad.net/ubuntu/+source/imagemagick/+bug/1796563
As a temporary fix, I edited /etc/ImageMagick-6/policy.xml and changed the PDF rights from none to read|write there. Not sure about the implications, but at least it allows me to get things done.
 
copy original, comment out, then edit copy to add read|write

this is from version 6.  Version 7 combines them into a single statement for pattern= clause.
  <!-- <policy domain="coder" rights="none" pattern="PDF" /> -->
  <policy domain="coder" rights="read | write" pattern="PDF" />

Another reference



--30--

Tuesday, July 19, 2016

Extracting images from a PDF

This example worked well for an example created by the Android Cam Scanner app, which I use to document and scan quite a lot.

convert -verbose -density 150 -trim -sharpen 0x1.0  -quality 100 ../1103-front-panel-card-ba11.pdf 1103.jpg

http://stackoverflow.com/questions/6605006/convert-pdf-to-image-with-high-resolution



from recommended solution from above link saved to make sure it doesn't vanish

173 vote

It appears that the following works:
convert           \
   -verbose       \
   -density 150   \
   -trim          \
    test.pdf      \
   -quality 100   \
   -sharpen 0x1.0 \
    24-18.jpg
It results in the top image Compare this to the result of my original command (image on the bottom):

 
(To really see and appreciate the differences between the two, right-click on each and select "Open Image in New Tab...".)
Also keep the following facts in mind:
  • The worse, blurry image on the right has a file size of 1.941.702 Bytes (1.85 MByte). Its resolution is 3060x3960 pixels, using 16-bit RGB color space.
  • The better, sharp image on the left has a file size of 337.879 Bytes (330 kByte). Its resolution is 758x996 pixels, using 8-bit Gray color space.
So, no need to resize; add the -density flag. The density value 150 is weird -- trying a range of values results in a worse looking image in both directions!

x