LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-03-2007, 06:47 AM   #16
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53

Quote:
Originally Posted by maroonbaboon
When you use

for i in IDC_Enterprise_Panel_20070618/*

you are trying to process all files, not just PNG ones. You need

for i in IDC_Enterprise_Panel_20070618/*.png
No, only .png files on this directory which was created with screenshots.

Re-test:-
$ for i in IDC_Enterprise_Panel_20070618/*.png ; do pngtopnm $i | pnmtops -noturn > ${i%.png}.ps ; done
Code:
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
pnmtops: warning, image too large for page, rescaling to 0.364286
pnmtops: writing color PostScript...
$ ls -l IDC_Enterprise_Panel_20070618/ | grep .ps
Code:
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session01.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session02.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session03.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session04.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session05.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session06.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session07.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session08.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:23 idc_enterprise_panel_20070618_resuming_session09.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session10.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session11.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session12.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session13.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session14.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session15.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session16.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session17.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session18.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session19.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session20.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:24 idc_enterprise_panel_20070618_resuming_session21.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:25 idc_enterprise_panel_20070618_resuming_session22.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:25 idc_enterprise_panel_20070618_resuming_session23.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:25 idc_enterprise_panel_20070618_resuming_session24.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:25 idc_enterprise_panel_20070618_resuming_session25.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:25 idc_enterprise_panel_20070618_resuming_session26.ps
-rw-r--r-- 1 satimis satimis 10760878 2007-07-03 18:25 idc_enterprise_panel_20070618_resuming_session_27.ps
$ gs -q -dNOPAUSE -dBATCH -sOutputFile=all.pdf -sDEVICE=pdfwrite IDC_Enterprise_Panel_20070618/*.ps

$ ls
Code:
all.pdf                        
IDC_Enterprise_Panel_20070618
It works, an all.pdf file created. Tks.


B.R.
satimis
 
Old 07-03-2007, 12:02 PM   #17
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi jschiwal,

Quote:
This one can be called like: pics2pdf book.pdf *.png
Code:
#!/bin/bash
if [ ${#} -lt 2 ]; then cat <<-EOF
        Usage: ${0} pdf-filename imagefile1 [ imagefile2 ] ...


        EOF
        exit 1;
        fi

pdffile="${1}"
shift 1
imagefiles=(${*})
infiles="${*}"
convert $infiles tmp.mng
convert tmp.mng $pdffile
rm tmp.mng
It won't handle whitespaces in filenames.
$ nano pcis2pdf.sh

copied;
Code:
if [ ${#} -lt 2 ]; then cat <<-EOF
        Usage: ${0} pdf-filename imagefile1 [ imagefile2 ] ...


        EOF
        exit 1;
        fi

pdffile="${1}"
shift 1
imagefiles=(${*})
infiles="${*}"
convert $infiles tmp.mng
convert tmp.mng $pdffile
rm tmp.mng
on it.

$ sudo chmod +x pics2pdf.sh

$ ls -l pics2pdf.sh
Code:
 
-rwxr-xr-x 1 satimis satimis 250 2007-07-03 23:57 pics2pdf.sh
$ sh pics2pdf.sh Test/IDC_Enterprise_Panel_20070618/*.png
Code:
pics2pdf.sh: 16: Syntax error: end of file unexpected (expecting "fi")
16 = empty space/line below "rm tmp.mng"


B.R.
satimis
 
Old 07-03-2007, 11:43 PM   #18
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
I've never used nano. Did you maybe save it in msdos mode. I tested the program out before posting it. Here I'll repost it in case there was a mistake posting it last time:
Code:
cat bin/pngs2pdf
#!/bin/bash
if [ ${#} -lt 2 ]; then cat <<-EOF
        Usage: ${0} pdf-filename imagefile1 [ imagefile2 ] ...


        EOF
        exit 1;
fi

pdffile="${1}"
shift 1
imagefiles=(${*})
infiles="${*}"
convert $infiles tmp.mng
convert tmp.mng $pdffile
rm tmp.mng
I unindented the "fi" command this time so that it would stand out. This is a cut-n-paste job after testing it three ways (renaming with an .sh extension; running it indirectly with "sh ~/bin/pngs2pdf sample3 *.JPG".

Yes, if the pictures are any graphic format that ImageMagick recognizes, you can use this script.

PS. The line after the rm command isn't in my original script. It is inserted by this site. This doesn't matter. There is one if command followed by one fi command. Also, don't copy the "cat bin/pngs2pdf" line. It isn't a part of the program. It's how I displayed the program in konsole.

PPS. One way to copy and paste from code on the web, to a file is to also have konsole (or a gnome equivalant) open as well as the webpage. Hightlight and copy the fragment in firefox; then go to the console and enter:
cat >filenameENTER

Then press the [INSERT] key or [CTRL]-V to paste it. Enter [RETURN] if you are on the last line, and then press [CTRL]-d to close the file. This is a lot quicker way to create a new file. You don't need to start nano or kate. (And you don't need to post something like the nano bit twice).

Last edited by jschiwal; 07-03-2007 at 11:52 PM.
 
Old 07-04-2007, 12:43 AM   #19
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
I retested it and it didn't work correctly when I used a larger number of pictures on the input. I guess it's back to the drawing board. I haven't tried to do the same manually yet. I need to check if convert expects the sizes to be similar, or something like that. I was getting only one of the pictures in the pdf. I'll comment out the "rm temp.mng" line and check how the intermediate file is.

Using autocompletion, to run pngs2pdf, I found that there is a png2mng.pl script that is a part of "kdesdk".

---

Update: convert didn't convert a list of 20 *.JPG files to a .mng file.

Last edited by jschiwal; 07-04-2007 at 01:27 AM.
 
Old 07-04-2007, 03:26 AM   #20
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Quote:
Originally Posted by jschiwal
I've never used nano. Did you maybe save it in msdos mode. I tested the program out before posting it. Here I'll repost it in case there was a mistake posting it last time:
Code:
cat bin/pngs2pdf
#!/bin/bash
if [ ${#} -lt 2 ]; then cat <<-EOF
        Usage: ${0} pdf-filename imagefile1 [ imagefile2 ] ...


        EOF
        exit 1;
fi

pdffile="${1}"
shift 1
imagefiles=(${*})
infiles="${*}"
convert $infiles tmp.mng
convert tmp.mng $pdffile
rm tmp.mng
I unindented the "fi" command this time so that it would stand out. This is a cut-n-paste job after testing it three ways (renaming with an .sh extension; running it indirectly with "sh ~/bin/pngs2pdf sample3 *.JPG".

Yes, if the pictures are any graphic format that ImageMagick recognizes, you can use this script.

PS. The line after the rm command isn't in my original script. It is inserted by this site. This doesn't matter. There is one if command followed by one fi command. Also, don't copy the "cat bin/pngs2pdf" line. It isn't a part of the program. It's how I displayed the program in konsole.

PPS. One way to copy and paste from code on the web, to a file is to also have konsole (or a gnome equivalant) open as well as the webpage. Hightlight and copy the fragment in firefox; then go to the console and enter:
cat >filenameENTER

Then press the [INSERT] key or [CTRL]-V to paste it. Enter [RETURN] if you are on the last line, and then press [CTRL]-d to close the file. This is a lot quicker way to create a new file. You don't need to start nano or kate. (And you don't need to post something like the nano bit twice).
Hi schiwal,

This time I started "text-editor" on Gnome desktop. Copied and pasted your script on the file. (The embedded codes of webpage won't be copied). Saved the file as pics2pdf.sh.


Then

$ sudo chmod +x pics2pdf.sh
$ sh pics2pdf.sh book.pdf Test/IDC_Enterprise_Panel_20070618/*.png
Code:
pics2pdf.sh: 18: Syntax error: end of file unexpected (expecting "fi")
The same complaint.


B.R.
satimis
 
Old 07-04-2007, 08:45 PM   #21
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Put the EOF at the beginning of the line. I think that your copy has spaces before it while mine has a tab.
The hyphen in "<<-EOF" allows you to indent the here document to make the program easier to read. I think that yours isn't ending at the EOF and so doesn't notice the fi statement.
 
Old 07-08-2007, 11:04 PM   #22
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Quote:
Originally Posted by jschiwal
Put the EOF at the beginning of the line. I think that your copy has spaces before it while mine has a tab.
The hyphen in "<<-EOF" allows you to indent the here document to make the program easier to read. I think that yours isn't ending at the EOF and so doesn't notice the fi statement.
Hi jschiwal,


Finally it works here. Steps performed as follows;

On the scripts;
1)
Changed
Code:
imagefiles=(${*})
as
Code:
imagefiles="${*}"
2) Moved "EOF" to left.

Finally script
Code:
#!/bin/bash
if [ ${#} -lt 2 ]; then cat <<-EOF
        Usage: ${0} pdf-filename imagefile1 [ imagefile2 ] ...


EOF
        exit 1;
fi

pdffile="${1}"
shift 1
imagefiles="${*}"
infiles="${*}"
convert $infiles tmp.mng
convert tmp.mng $pdffile
rm tmp.mng

$ sh pics2pdf.sh book.pdf Test/IDC_Enterprise_Panel_20070618/*.png

I watched the process on "File Browser". First a "tmp.mng" file of 2.7M was created. Then the said file was converted to book.pdf, 2.5M. On my slow PC (an old P-III box with 384MB Ram) it took >10 min to complete.

Tks for your advice.


B.R.
satimis
 
Old 07-08-2007, 11:14 PM   #23
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
I have an old PIII laptop that I put Fedora Core 6 on just to play with with the distro and have a reference to answer questions.

Last edited by jschiwal; 07-09-2007 at 04:15 AM.
 
Old 07-21-2007, 04:23 AM   #24
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Rep: Reputation: 51
Quote:
Originally Posted by jschiwal
You could also use ImageMagick.

convert *.png book.mng
convert book.mng book.pdf
This did put all the pages on a pdf cotaining one single page.
can it create serverral pages ? (one per jpg)

thanks


--
I found :
Code:
convert -page A4+0+0 *.jpg book.ps
then you can convert the ps to pdf

Last edited by frenchn00b; 07-21-2007 at 04:32 AM.
 
Old 08-04-2007, 07:05 AM   #25
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Rep: Reputation: 51
Code:
for each in $(ls *.png)  ; do convert $each $each_.pdf ; done
or sthg like this with some sed
 
  


Reply

Tags
batch, convert, jpg, pdf, png


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot print PDF files. mooreted Mandriva 17 01-02-2012 04:11 AM
Print-to-file print driver to print PDF Bill Fox Linux - General 3 05-02-2006 05:15 PM
Cannot Print PDF Files as400 Solaris / OpenSolaris 41 04-24-2006 03:23 AM
How To Merge multiple files into a single PDF ? kkempter Linux - Software 1 10-28-2005 02:02 PM
why I can't print PDF files wannaluvlinux Linux - Software 3 10-13-2004 03:52 AM


All times are GMT -5. The time now is 10:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration