Blog

  • Create an Image Tiling App with Python & Gradio

    πŸ“Έ

    Want to generate a tiled pattern from an image? Here’s a simple Python app using Pillow and Gradio to let users resize an image and tile it as a grid. πŸš€

    πŸ›  What You’ll Need

    • Pillow: For image processing
    • Gradio: To create a simple web UI

    πŸ“Œ Step 1: Install Dependencies

    Make sure you have the required libraries installed:

    pip install pillow gradio

    πŸ“Œ Step 2: Create the Python Script

    Here’s the full code to create the tiling app:

    from PIL import Image
    import gradio as gr
    
    def tile_image(img, resize_value, repeat_x, repeat_y):
        # Resize input image
        img = img.resize((resize_value, resize_value))
        
        # Calculate new image dimensions
        new_width = img.width * repeat_x
        new_height = img.height * repeat_y
        
        # Create blank canvas
        new_img = Image.new('RGB', (new_width, new_height))
        
        # Tile the image
        for i in range(repeat_x):
            for j in range(repeat_y):
                new_img.paste(img, (i * img.width, j * img.height))
        
        return new_img
    
    # Gradio UI
    iface = gr.Interface(
        fn=tile_image,
        inputs=[
            gr.Image(type="pil", label="Upload Image"),
            gr.Slider(50, 500, step=10, label="Resize Image"),
            gr.Slider(1, 10, step=1, label="Horizontal Repeats"),
            gr.Slider(1, 10, step=1, label="Vertical Repeats")
        ],
        outputs=gr.Image(type="pil"),
        title="Image Tiling Generator",
        description="Upload an image, resize it, and set horizontal & vertical repeats to generate a tiled pattern.",
        live=True
    )
    
    if __name__ == "__main__":
        iface.launch()
    

    πŸ“Œ Step 3: Run the App

    Run the script and Gradio will launch a web interface:

    python image_tiling.py

    You can now upload an image, choose the resize value, and set tiling parameters to generate a patterned output.

    ✨ Enjoy creating beautiful image mosaics! ✨

    Let me know if you have any questions! πŸ˜ŠπŸš€

  • Hello coders!

    Welcome to The Open-Source Lab – Where Code Meets Creativity!

    Hello and welcome! πŸš€ If you’re passionate about coding, AI, open-source projects, and practical software tools, you’ve landed in the right place.

    What You’ll Find Here

    • Step-by-step coding tutorials – From Python scripts to full-stack applications.
    • AI & IoT experiments – Bringing intelligence to hardware.
    • Open-source innovations – Exploring tools that empower developers.
    • Tech insights & best practices – Tips to improve your coding journey.

    Why This Blog?

    I created this space to share my love for technology and help others build cool things. Whether you’re a beginner or an experienced developer, my goal is to provide easy-to-follow guides and useful insights to make coding fun and accessible.

    Stay tuned for exciting projects, practical tutorials, and deep dives into the world of AI, IoT, and open-source software! Let’s build something amazing together. πŸ’‘

    Happy coding!