I'm struggling a little with the command line running imagemagick.

I need to convert many .jpg files to many PDF files. Each PDF has one jpg contained inside. I fount lots of tutorials on how to convert many jpg to one PDF, but this is not what I need.

Anywho, I would not mind paying a small bounty for a correct solution that I could handle.

link|improve this question
2  
You don't need a bounty, but you'd be better off explaining what your ultimate goal is, as there isn't enough detail to give a good answer. For example, do you wish to have these printed? Do you need to send them to someone or something that can't cope with a jpg. Do you wish to embed them in something else? There are answers for all of these, easy ones, but I'd rather give the right one. – msw Jul 10 '10 at 6:24
feedback

2 Answers

up vote 1 down vote accepted

I'm not sure what's tripping you up, but one way is to figure out how to convert one jpg to one pdf, then wrap that command in a bash for loop.

Convert one file

convert [convert options] file.jpg file.pdf

Put it in a loop, with quoting to handle filenames with spaces. The ${f$.jpg}.pdf construct replaces the .jpg extension with .pdf. Here's a bash script.

#!/bin/bash
# Script to convert all jpg files in current directory
# to pdf files
# Edit the convert line to include convert options ahead of "$f"

for f in *.jpg
do
convert "$f" "${f%.jpg}.pdf"
done

Put the script in the directory with the jpg files, make the script executable and run it with the command ./scriptname.

link|improve this answer
to W_Whalley This is what I needed. I was already able to CONVERT one file at a time. I could not figure out the syntax for the loop. I wonder if would be ironic to label myself a "Noob" on a forum called "SUPERUSER"? Anyway, thanks for the quick response, it is exactly what I needed. send me your paypal, and I'd be happy to drop you 10$us.(public---toddheffley.com) todd – Todd Jul 11 '10 at 12:41
Worked great. todd – Todd Jul 11 '10 at 12:59
No need for cash. Glad to help. If you accept the answer, that's thanks enough. – W_Whalley Jul 11 '10 at 14:52
@Todd: why didn't you upvote the answer? (I did now. You should too.) – pipitas Jul 28 '10 at 0:10
feedback

For processing many images, ImageMagick provides the command mogrify which would be invoked like this:

 mogrify -format pdf *.jpg

To output in another directory, you can add the -path switch.

(I see that this particular problem is already solved, but happened upon the question and thought I'd add this for future reference).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.