Skip to content

Commit

Permalink
Add Tutorial AND remake README.md
Browse files Browse the repository at this point in the history
This is pretty much it.
  • Loading branch information
Jangsoodlor committed Apr 19, 2022
1 parent f35a50f commit 3e32a1d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 28 deletions.
28 changes: 14 additions & 14 deletions JPG2PDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ def openFolder():
file_path = filedialog.askdirectory()
return file_path

def AspCalc(w,h,im1):
a = im1.width // w
b = im1.height // a
if b <= h:
return int(b)
elif b > h:
c = im1.height // h
d = im1.width // c
return int(d)

while True:
# -------------- TUTORIAL ----#

print("JPG-to-PDF with CLI v.3.2.0" + '\n' + 'Copyright (c) 2022 Jangsoodlor. All rights reserved.' + '\n')
print('Please move all of your pictures that you desired to be convert to a PDF file one folder before using this program.' + '\n'
+ 'If you left your field blank, the configuration of your PDF document will be automatically set by the default parameters.'+'\n')
+ 'If you left your field blank, the configuration of your PDF document will be automatically set by the default parameters.'+'\n'+'The outputted file will be located in the directory of your folder that is containing your images.'+'\n')

# --------------- USER INPUT -------------------- #

Expand Down Expand Up @@ -71,33 +81,23 @@ def openFolder():
for i in range(0, len(imagelist)):
im1 = Image.open(imagelist[i]) # Open the image.
print(im1)
width, height = im1.size # Get the width and height of that image.

def AspCalc():
a = im1.width // w
b = im1.height // a
if b <= h:
return int(b)
elif b > h:
c = im1.height // h
d = im1.width // c
return int(d)
width, height = im1.size # Get the width and height of that image.

if width > height:
if aspect.lower() == 'n':
pdf.add_page('L')
pdf.image(imagelist[i], 0, 0, h, w)
elif aspect.lower() == 'y':
pdf.add_page('L')
pdf.image(imagelist[i], 0, 0, h, AspCalc())
pdf.image(imagelist[i], 0, 0, h, AspCalc(w,h,im1))

if width <= height:
if aspect.lower() == 'n':
pdf.add_page('P')
pdf.image(imagelist[i], 0, 0, w, h)
elif aspect.lower() == 'y':
pdf.add_page('P')
pdf.image(imagelist[i], 0, 0, w, AspCalc())
pdf.image(imagelist[i], 0, 0, w, AspCalc(w,h,im1))


pdf.output(folder + '\\' + name + '.pdf' , 'F') # Save the PDF.
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# JPG-to-PDF with CLI
Simple Python script to convert a set of images to PDF and combine them into one single PDF file within seconds. Based on [praneetk2704's JPG-to-PDF](https://github.com/praneetk2704/JPG-to-PDF)
<br /><br />
![screenshot_1](/piktur/demonstration.png)

Does your teacher requires you to submit your assignment in PDF but you do your works with pen and paper because you can't stand working on iPad? Well, this tool is make for YOU!
Does your teacher requires you to submit your assignment in PDF but you have to work with pen and paper? Well, this tool is made for YOU!

This is a simple Python script to convert images to PDF and combine them into one single PDF file. Based on [praneetk2704's JPG-to-PDF](https://github.com/praneetk2704/JPG-to-PDF)
<br /><br />
![screenshot_1](/pic/demonstration-new.png)

## Features
This program asks you 3 questions.
1. Your folder containing your images.
2. Your desired document name.
3. Whether or not do you want to auto-rotate a page containing landscape image to a landscape page
## OK Cool, But how do I use it?
First, you download the executable file in the release tab on the right to your computer. Open it and then follow the instructions on the screen.

The outputted file will be located in the directory of your folder that is containing your images.
### demonstrations
![demo](/pic/how1.png)
![demo](/pic/how2.png)
![demo](/pic/how3.png)
![demo](/pic/how4.png)

## Building
You're required to install 3 dependencies from pip. Which are:
You're required to install 2 dependencies from pip. Which are:
```bash
fpdf
pillow
Expand Down
Binary file added pic/demonstration-new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/how1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/how2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/how3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/how4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed piktur/demonstration.png
Binary file not shown.
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

0 comments on commit 3e32a1d

Please sign in to comment.