Converting pdf pictures to png files makes pictures too small

conversionimagemagickimagespdf

I'm converting a bunch of pdf vector figures to png files.

for f in *.pdf
   do convert -trim ${f} "${f}.png"
done
rename 's/\.pdf//' *.png

But the dimension of the pictures are too small.

The doc of convert tells a -size width height option but I cannot specify a unique size for all pictures. Any other ways?

Best Answer

Use the -density option to define how many pixels you want per inch; the default is -density 72.

Also, since you're using Bash, you can directly manipulate the file name in the loop:

for src in *.pdf ; do
    convert -trim "${src}" "${src%.*}.png"
done

without having to do a post-rename. ${src%.*} in Bash evaluates to the contents of src, but with everything following a final . removed. (If src does not contain ., ${src%.*} evaluates to the same as $src.)