HTML/CSS

The construction of shanedraper.com involved the utilization of HTML, CSS, and JavaScript to create an interface that prioritizes user experience. The site's design integrates responsive features to ensure smooth navigation across devices. The interactive elements, shaped by my proficiency in various programming languages, enable dynamic engagement for visitors. Regular updates are implemented to align with evolving web technologies, maintaining a contemporary online presence. The development process was marked by a commitment to functional design and efficient code, underscoring a pragmatic approach to website creation.

Back (Python) Next (JS)

SQL

In this project I showcase my handling of data using SQL from inception to aggregation. Optimization techniques assure seamless scalability, while insightful reports, empowered by aggregation functions and subqueries, uncover actionable insights. Automated processes through stored procedures and functions streamline operations, and robust security protocols—featuring user roles, permissions, and meticulous data access control—safeguard your valuable information. This is a comprehensive view of Shane's analytical capabilities, delivering an efficient and secure database.

SQL Project / Sample Work)

Back (JS) Next (Python)

Python

This Python script (see below) is a graphical user interface (GUI) application that facilitates the conversion of PDF files to JPG images. The code utilizes the customtkinter library for creating the user interface components. The user can select an input directory containing PDF files and an output directory where the converted JPG images will be saved.

The script employs the pdf2image library to convert each PDF file into a sequence of images. It uses the convert_from_path function to extract the images from the PDFs. If any errors occur during the conversion process, they are handled and the script continues processing the remaining PDFs.

The user has the option to specify whether the first and last pages of each PDF are spreads. If enabled, the script crops and resizes the images accordingly, creating a visually appealing result. The size of the first non-cover page is used as a reference for resizing subsequent images.

The GUI includes various components, such as labels, buttons, checkboxes, and progress bars, to interact with the user and provide feedback during the conversion process. The progress of both individual PDF conversions and the overall conversion process is displayed using progress bars.

Once the conversion is complete, a success message is displayed to the user.

Overall, this script provides a user-friendly way to batch convert PDF files into JPG images while offering options for adjusting the appearance of the output images.

Back (SQL) Next (HTML)

Code for the PDF to JPG Converter:

                                
import customtkinter as ctk
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
from tkinter import ttk
from pdf2image import convert_from_path
from pdf2image.exceptions import PDFPageCountError
from PIL import Image, ImageDraw
import os

def crop_to_half(image, left_half=True):
	width, height = image.size
	if left_half:
		cropped_image = image.crop((0, 0, width // 2, height))
	else:
		cropped_image = image.crop((width // 2, 0, width, height))
	return cropped_image

def resize_image(image, desired_size):
	"""Resize an image to the desired size without preserving aspect ratio."""
	return image.resize(desired_size, Image.LANCZOS)

def convert_pdf_to_jpg(input_dir, output_dir, progress_var, max_progress_var, progressbar, progressbar_label, cover_spreads=True):
	pdf_files = [file for file in os.listdir(input_dir) if file.lower().endswith('.pdf')]
	max_progress_var.set(len(pdf_files))

	size_of_first_page = None  # Variable to store the size of the first non-cover page

	for pdf_index, pdf_file in enumerate(pdf_files):
		pdf_name = os.path.splitext(pdf_file)[0]
		jpg_dir = os.path.join(output_dir, pdf_name)
		os.makedirs(jpg_dir, exist_ok=True)

		pdf_path = os.path.join(input_dir, pdf_file)
		try:
			images = convert_from_path(pdf_path)
		except PDFPageCountError as e:
			print(f"Error occurred while converting PDF: {pdf_file}")
			print("The PDF might be encrypted or contain scanned pages.")
			continue
		except Exception as e:
			print(f"Error occurred while converting PDF: {pdf_file}")
			print(f"Error details: {str(e)}")
			continue

		sub_progressbar = ttk.Progressbar(root, length=400, mode='determinate', maximum=len(images))
		sub_progressbar.pack(pady=10)

		for img_index, image in enumerate(images):
			# First image (front cover)
			if img_index == 0 and cover_spreads:
				image = crop_to_half(image, left_half=False)
			# Last image (back cover)
			elif img_index == len(images) - 1 and cover_spreads:
				image = crop_to_half(image, left_half=True)

			if size_of_first_page is None and img_index > 0:
				size_of_first_page = image.size  # Assign the size of the first non-cover page

			# Resize the image to the size of the first non-cover page
			if size_of_first_page is not None:
				image = image.resize(size_of_first_page, Image.BICUBIC)

			page_number = str(img_index + 1).zfill(3)
			jpg_path = os.path.join(jpg_dir, f"{page_number}.jpg")
			try:
				image.save(jpg_path, "JPEG")
			except Exception as e:
				print(f"Error occurred while saving JPG: {jpg_path}")
				print(f"Error details: {str(e)}")

			sub_progressbar['value'] = img_index + 1
			root.update()

		sub_progressbar.pack_forget()
		progressbar['value'] = pdf_index + 1

		progress_percentage = (pdf_index + 1) * 100 // len(pdf_files)
		progress_var.set(progress_percentage)
		progressbar_label.configure(text=f"\nProcessing PDFs: {pdf_index + 1}/{len(pdf_files)} - {progress_percentage}%")
		root.update()

	print("Conversion completed successfully.")

def select_input_directory():
	dir_name = filedialog.askdirectory()
	input_dir_var.set(dir_name)

def select_output_directory():
	dir_name = filedialog.askdirectory()
	output_dir_var.set(dir_name)

def convert():
	global progressbar

	input_dir = input_dir_var.get()
	output_dir = output_dir_var.get()
	cover_spreads = cover_spreads_var.get()
	if input_dir and output_dir:
		progress_label.configure(text="Conversion Progress")
		progress_label.pack()
		progressbar_label.configure(text="Processing PDFs...")
		progressbar_label.pack()

		progressbar = ttk.Progressbar(root, length=400, mode='determinate', maximum=100, variable=progress_var)
		progressbar.pack(pady=5)

		convert_pdf_to_jpg(input_dir, output_dir, progress_var, max_progress_var, progressbar, progressbar_label, cover_spreads)
		messagebox.showinfo('Success', 'Conversion completed successfully.')

		progressbar.pack_forget()
		progressbar_label.pack_forget()
		progress_label.pack_forget()
	else:
		messagebox.showwarning('Warning', 'Please select both directories.')


root = ctk.CTk()
root.geometry("700x500")
root.title("PDF to JPG Converter")

title_label = ctk.CTkLabel(root, text="PDF to JPG", font=ctk.CTkFont(size=30, weight="bold"))
title_label.pack(pady=(30, 5))

instruction_label = ctk.CTkLabel(root, text="Select a folder containing PDF files and a folder where you want the converted JPG’s to be saved.")
instruction_label.pack(pady=(10, 20))

input_dir_var = ctk.StringVar()
output_dir_var = ctk.StringVar()
progress_var = tk.IntVar()
max_progress_var = tk.IntVar()

input_frame = ctk.CTkFrame(root)
input_frame.pack(pady=15)
ctk.CTkLabel(input_frame, text="Input Directory (PDF):").pack(padx=10)
ctk.CTkEntry(input_frame, textvariable=input_dir_var).pack(side=ctk.LEFT)
pdf_button = ctk.CTkButton(input_frame, text='Browse', command=select_input_directory)
pdf_button.pack(padx=10)

output_frame = ctk.CTkFrame(root)
output_frame.pack(pady=15)
ctk.CTkLabel(output_frame, text="Output Directory (JPG):").pack(padx=10)
ctk.CTkEntry(output_frame, textvariable=output_dir_var).pack(side=ctk.LEFT)
jpg_button = ctk.CTkButton(output_frame, text='Browse', command=select_output_directory)
jpg_button.pack(padx=10)

cover_spreads_var = tk.BooleanVar()
cover_spreads_var.set(False)
cover_spreads_checkbox = ctk.CTkCheckBox(root, text="First and last pages are spreads", variable=cover_spreads_var)
cover_spreads_checkbox.pack()

button_frame = ctk.CTkFrame(root)
button_frame.pack(pady=15)

convert_button = ctk.CTkButton(button_frame, text='Convert', command=convert, fg_color="green", hover_color="dark green")
convert_button.pack()

progress_label = ctk.CTkLabel(root)
progressbar_label = ctk.CTkLabel(root)
progressbar = ttk.Progressbar(root, length=400, mode='determinate', maximum=100, variable=progress_var)

root.mainloop()									
								
                            

Back (SQL) Next (HTML)