<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Image size reducer website using python]]></title><description><![CDATA[Image size reducer website using python]]></description><link>https://image-size-reducer-website-using-python.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 07:36:26 GMT</lastBuildDate><atom:link href="https://image-size-reducer-website-using-python.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Image size reducer using python]]></title><description><![CDATA[How to Create an Image Size Reducer Website Using Python
Reducing image size without losing too much quality is crucial for web optimization, faster load times, and saving bandwidth. In this tutorial, we'll walk you through creating a simple image si...]]></description><link>https://image-size-reducer-website-using-python.hashnode.dev/image-size-reducer-using-python</link><guid isPermaLink="true">https://image-size-reducer-website-using-python.hashnode.dev/image-size-reducer-using-python</guid><category><![CDATA[Python]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Google]]></category><category><![CDATA[learning]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[Programming Tips]]></category><dc:creator><![CDATA[Notz]]></dc:creator><pubDate>Tue, 15 Jul 2025 04:09:07 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-how-to-create-an-image-size-reducer-website-using-python">How to Create an Image Size Reducer Website Using Python</h1>
<p>Reducing image size without losing too much quality is crucial for web optimization, faster load times, and saving bandwidth. In this tutorial, we'll walk you through creating a <strong>simple image size reducer website using Python</strong> with Flask for the backend and Pillow for image processing.</p>
<p>By the end, you'll have a web app where users can upload images and get a compressed version for download.</p>
<hr />
<h2 id="heading-tools-amp-technologies">🧰 Tools &amp; Technologies</h2>
<ul>
<li><p><strong>Python 3.x</strong></p>
</li>
<li><p><strong>Flask</strong> – lightweight web framework</p>
</li>
<li><p><strong>Pillow</strong> – Python Imaging Library (PIL Fork)</p>
</li>
<li><p><strong>HTML/CSS</strong> – Frontend</p>
</li>
<li><p><strong>Bootstrap</strong> – Optional for quick styling</p>
</li>
</ul>
<hr />
<h2 id="heading-step-1-setup-your-environment">📦 Step 1: Setup Your Environment</h2>
<p>Create a folder for your project:</p>
<pre><code class="lang-plaintext">bashCopyEditmkdir image-resizer
cd image-resizer
</code></pre>
<p>Set up a virtual environment (optional but recommended):</p>
<pre><code class="lang-plaintext">bashCopyEditpython -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
</code></pre>
<p>Install required packages:</p>
<pre><code class="lang-plaintext">bashCopyEditpip install Flask Pillow
</code></pre>
<hr />
<h2 id="heading-project-structure">📁 Project Structure</h2>
<pre><code class="lang-plaintext">arduinoCopyEditimage-resizer/
│
├── app.py
├── static/
│   └── uploads/
├── templates/
│   ├── index.html
│   └── result.html
</code></pre>
<hr />
<h2 id="heading-step-2-create-the-flask-app-apppyhttpapppy">🧠 Step 2: Create the Flask App (<a target="_blank" href="http://app.py"><code>app.py</code></a>)</h2>
<pre><code class="lang-plaintext">pythonCopyEditfrom flask import Flask, render_template, request, send_from_directory
from PIL import Image
import os
import uuid

app = Flask(__name__)
UPLOAD_FOLDER = 'static/uploads'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

# Ensure upload directory exists
os.makedirs(UPLOAD_FOLDER, exist_ok=True)

@app.route('/', methods=['GET', 'POST'])
def index():
    if request.method == 'POST':
        image = request.files['image']
        quality = int(request.form.get('quality', 70))
        if image:
            filename = f"{uuid.uuid4().hex}.jpg"
            filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)

            # Open and compress the image
            img = Image.open(image)
            img = img.convert('RGB')  # Ensure it's JPEG-compatible
            img.save(filepath, optimize=True, quality=quality)

            return render_template('result.html', filename=filename)
    return render_template('index.html')

@app.route('/download/&lt;filename&gt;')
def download_file(filename):
    return send_from_directory(app.config['UPLOAD_FOLDER'], filename, as_attachment=True)

if __name__ == '__main__':
    app.run(debug=True)
</code></pre>
<hr />
<h2 id="heading-step-3-create-frontend-templates">🌐 Step 3: Create Frontend Templates</h2>
<h3 id="heading-templatesindexhtml"><code>templates/index.html</code></h3>
<pre><code class="lang-plaintext">htmlCopyEdit&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Image Size Reducer&lt;/title&gt;
  &lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"&gt;
&lt;/head&gt;
&lt;body class="container py-5"&gt;
  &lt;h2 class="mb-4"&gt;Reduce Your Image Size&lt;/h2&gt;
  &lt;form method="POST" enctype="multipart/form-data"&gt;
    &lt;div class="mb-3"&gt;
      &lt;input type="file" name="image" accept="image/*" required class="form-control"&gt;
    &lt;/div&gt;
    &lt;div class="mb-3"&gt;
      &lt;label for="quality"&gt;Quality (1-100):&lt;/label&gt;
      &lt;input type="number" name="quality" min="1" max="100" value="70" class="form-control" required&gt;
    &lt;/div&gt;
    &lt;button type="submit" class="btn btn-primary"&gt;Compress Image&lt;/button&gt;
  &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<h3 id="heading-templatesresulthtml"><code>templates/result.html</code></h3>
<pre><code class="lang-plaintext">htmlCopyEdit&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Image Compressed&lt;/title&gt;
  &lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"&gt;
&lt;/head&gt;
&lt;body class="container py-5"&gt;
  &lt;h2&gt;Your Compressed Image&lt;/h2&gt;
  &lt;img src="{{ url_for('static', filename='uploads/' + filename) }}" class="img-fluid my-3" alt="Compressed"&gt;
  &lt;br&gt;
  &lt;a href="{{ url_for('download_file', filename=filename) }}" class="btn btn-success"&gt;Download Image&lt;/a&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;a href="/" class="btn btn-secondary"&gt;Compress Another&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<hr />
<h2 id="heading-step-4-run-the-app">🚀 Step 4: Run the App</h2>
<p>Run the server:</p>
<pre><code class="lang-plaintext">bashCopyEditpython app.py
</code></pre>
<p>Open your browser and go to <a target="_blank" href="http://127.0.0.1:5000/"><code>http://127.0.0.1:5000/</code></a>.</p>
<hr />
<h2 id="heading-features-you-can-add">✅ Features You Can Add</h2>
<ul>
<li><p>Drag-and-drop image upload</p>
</li>
<li><p>Resize by dimensions</p>
</li>
<li><p>Support for multiple file types</p>
</li>
<li><p>Upload progress bar</p>
</li>
<li><p>History of recent downloads</p>
</li>
</ul>
<hr />
<h2 id="heading-conclusion">🎯 Conclusion</h2>
<p>In just a few steps, we built a functioning image compressor web app using Python and Flask. With Pillow, image compression is quick and effective, and Flask makes web integration simple and elegant.</p>
<p>Want to make it production-ready? Deploy on Heroku, Render, or Railway with a few configuration tweaks.</p>
]]></content:encoded></item></channel></rss>