How to convert multiply jpg files ? #13

Closed
opened 3 years ago by josch · 0 comments
josch commented 3 years ago
Owner

By josch on 2015-03-15T09:41:50.663Z

Created by: gregg128

How dow I convert 100 files into 1 pdf file ? Thank you!

Imported comments:

By josch on 2013-11-16 22:02:35 UTC

By giving them on the commandline. Does it not work?

By gregg128 on 2013-11-16 22:08:40 UTC

img2pdf.py -o new.pdf *.jpg
Traceback (most recent call last):
File "/home/grigory/bin/img2pdf.py", line 294, in
args.subject, args.keywords, args.colorspace, args.verbose))
File "/home/grigory/bin/img2pdf.py", line 229, in main
debug_out("input dpi (forced) = %d x %d"%dpi)
TypeError: %d format: a number is required, not tuple

By gregg128 on 2013-11-16 22:09:10 UTC

should I list all 100 jpg files as argument ? o_O

By gregg128 on 2013-11-16 22:09:35 UTC

It works perfectly with 1 file, but not with all of them.

By josch on 2013-11-16 22:15:14 UTC

You dont have to list 100 jpeg files as arguments manually. That's what globbing is for and you used it by specifying *.jpg. Your shell will do the task of converting that expressing to however many filenames match it and pass those as arguments to the program you run.

You indeed discovered a bug. I think I fixed it now. Please confirm.

By gregg128 on 2013-11-16 22:46:05 UTC

Yeah it works! Thank you.


By gothku on 2017-08-09T00:45:02.321Z


I used WinPython on Windows 7 and tried to ask img2pdf to read jpg files in the directory under scripts/img/

D:\WinPython-64bit-3.6.1.0Zero\scripts>img2pdf --output out.pdf ./img/*.
jpg

This is what I get.

Traceback (most recent call last):
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\Scripts\img2pd
f-script.py", line 11, in
load_entry_point('img2pdf==0.2.4', 'console_scripts', 'img2pdf')()
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\site-packa
ges\img2pdf.py", line 1700, in main
args = parser.parse_args()
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p
y", line 1730, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p
y", line 1762, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p
y", line 1971, in _parse_known_args
stop_index = consume_positionals(start_index)
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p
y", line 1927, in consume_positionals
take_action(action, args)
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p
y", line 1820, in take_action
argument_values = self._get_values(action, argument_strings)
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p
y", line 2275, in _get_values
value = [self._get_value(action, v) for v in arg_strings]
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p
y", line 2275, in
value = [self._get_value(action, v) for v in arg_strings]
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p
y", line 2290, in _get_value
result = type_func(arg_string)
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\site-packa
ges\img2pdf.py", line 1244, in input_images
if os.path.getsize(path) == 0:
File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\genericpat
h.py", line 50, in getsize
return os.stat(filename).st_size
OSError: [WinError 123] 檔案名稱、目錄名稱或磁碟區標籤語法錯誤。: './img/*.jpg'

Please help.
Thanks


By josch on 2017-08-09T10:09:53.901Z


Did you read the rest of this bug report?

Why do you comment on a closed bug report?

Which shell are you using?


By gothku on 2017-08-11T00:41:49.729Z


I googled and found this issue is relevant to my case.

You said, "You dont have to list 100 jpeg files as arguments manually. That's what globbing is for and you used it by specifying *.jpg. Your shell will do the task of converting that expressing to however many filenames match it and pass those as arguments to the program you run." But it does not in my case.

The shell I am using is WinPython Command Prompt under WinPython-64bit-3.6.1.0Zero

Thank you.


By josch on 2017-08-11T01:19:35.630Z


Then that's a bug in your shell and not in img2pdf. As I wrote, it's your shell that is doing the globbing and not img2pdf. If your shell doesn't understand the globbing expression *.jpg then there is nothing img2pdf can do about it.

*By josch on 2015-03-15T09:41:50.663Z* *Created by: gregg128* How dow I convert 100 files into 1 pdf file ? Thank you! **Imported comments:** *By josch on 2013-11-16 22:02:35 UTC* By giving them on the commandline. Does it not work? *By gregg128 on 2013-11-16 22:08:40 UTC* img2pdf.py -o new.pdf *.jpg Traceback (most recent call last): File "/home/grigory/bin/img2pdf.py", line 294, in <module> args.subject, args.keywords, args.colorspace, args.verbose)) File "/home/grigory/bin/img2pdf.py", line 229, in main debug_out("input dpi (forced) = %d x %d"%dpi) TypeError: %d format: a number is required, not tuple *By gregg128 on 2013-11-16 22:09:10 UTC* should I list all 100 jpg files as argument ? o_O *By gregg128 on 2013-11-16 22:09:35 UTC* It works perfectly with 1 file, but not with all of them. *By josch on 2013-11-16 22:15:14 UTC* You dont have to list 100 jpeg files as arguments manually. That's what globbing is for and you used it by specifying *.jpg. Your shell will do the task of converting that expressing to however many filenames match it and pass those as arguments to the program you run. You indeed discovered a bug. I think I fixed it now. Please confirm. *By gregg128 on 2013-11-16 22:46:05 UTC* Yeah it works! Thank you. --- *By gothku on 2017-08-09T00:45:02.321Z* --- I used WinPython on Windows 7 and tried to ask img2pdf to read jpg files in the directory under scripts/img/ D:\WinPython-64bit-3.6.1.0Zero\scripts>img2pdf --output out.pdf ./img/*. jpg This is what I get. Traceback (most recent call last): File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\Scripts\img2pd f-script.py", line 11, in <module> load_entry_point('img2pdf==0.2.4', 'console_scripts', 'img2pdf')() File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\site-packa ges\img2pdf.py", line 1700, in main args = parser.parse_args() File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p y", line 1730, in parse_args args, argv = self.parse_known_args(args, namespace) File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p y", line 1762, in parse_known_args namespace, args = self._parse_known_args(args, namespace) File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p y", line 1971, in _parse_known_args stop_index = consume_positionals(start_index) File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p y", line 1927, in consume_positionals take_action(action, args) File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p y", line 1820, in take_action argument_values = self._get_values(action, argument_strings) File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p y", line 2275, in _get_values value = [self._get_value(action, v) for v in arg_strings] File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p y", line 2275, in <listcomp> value = [self._get_value(action, v) for v in arg_strings] File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\argparse.p y", line 2290, in _get_value result = type_func(arg_string) File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\site-packa ges\img2pdf.py", line 1244, in input_images if os.path.getsize(path) == 0: File "D:\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\genericpat h.py", line 50, in getsize return os.stat(filename).st_size OSError: [WinError 123] 檔案名稱、目錄名稱或磁碟區標籤語法錯誤。: './img/*.jpg' Please help. Thanks --- *By josch on 2017-08-09T10:09:53.901Z* --- Did you read the rest of this bug report? Why do you comment on a closed bug report? Which shell are you using? --- *By gothku on 2017-08-11T00:41:49.729Z* --- I googled and found this issue is relevant to my case. You said, "You dont have to list 100 jpeg files as arguments manually. That's what globbing is for and you used it by specifying *.jpg. Your shell will do the task of converting that expressing to however many filenames match it and pass those as arguments to the program you run." But it does not in my case. The shell I am using is WinPython Command Prompt under WinPython-64bit-3.6.1.0Zero Thank you. --- *By josch on 2017-08-11T01:19:35.630Z* --- Then that's a bug in your shell and not in img2pdf. As I wrote, it's your *shell* that is doing the globbing and not img2pdf. If your shell doesn't understand the globbing expression `*.jpg` then there is nothing img2pdf can do about it.
josch closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: josch/img2pdf#13
Loading…
There is no content yet.