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

for f in *.pdf
   do convert -trim ${f} "${f}.png"
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?

1 Answer 1


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"

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.)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .