• Latest
  • Trending
Make image Instagram compatible using Python

Make image Instagram compatible using Python

May 25, 2022
Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025
ATC Ghana supports Girls-In-ICT Program

ATC Ghana supports Girls-In-ICT Program

April 25, 2023
Vice President Dr. Bawumia inaugurates  ICT Hub

Vice President Dr. Bawumia inaugurates ICT Hub

April 2, 2023
Co-Creation Hub’s edtech accelerator puts $15M towards African startups

Co-Creation Hub’s edtech accelerator puts $15M towards African startups

February 20, 2023
Data Leak Hits Thousands of NHS Workers

Data Leak Hits Thousands of NHS Workers

February 20, 2023
EU Cybersecurity Agency Warns Against Chinese APTs

EU Cybersecurity Agency Warns Against Chinese APTs

February 20, 2023
How Your Storage System Will Still Be Viable in 5 Years’ Time?

How Your Storage System Will Still Be Viable in 5 Years’ Time?

February 20, 2023
The Broken Promises From Cybersecurity Vendors

Cloud Infrastructure Used By WIP26 For Espionage Attacks on Telcos

February 20, 2023
Instagram and Facebook to get paid-for verification

Instagram and Facebook to get paid-for verification

February 20, 2023
YouTube CEO Susan Wojcicki steps down after nine years

YouTube CEO Susan Wojcicki steps down after nine years

February 20, 2023
Inaugural AfCFTA Conference on Women and Youth in Trade

Inaugural AfCFTA Conference on Women and Youth in Trade

September 6, 2022
  • Consumer Watch
  • Kids Page
  • Directory
  • Events
  • Reviews
Thursday, 16 July, 2026
  • Login
itechnewsonline.com
  • Home
  • Tech
  • Africa Tech
  • InfoSEC
  • Data Science
  • Data Storage
  • Business
  • Opinion
Subscription
Advertise
No Result
View All Result
itechnewsonline.com
No Result
View All Result

Make image Instagram compatible using Python

by ITECHNEWS
May 25, 2022
in Data Science, Leading Stories
0 0
0
Make image Instagram compatible using Python

Image processing is quite easy and fast in Python with libraries available. I recently was trying to make images Instagram-friendly using Python script.

What do I mean Instagram Friendly Images:

YOU MAY ALSO LIKE

French Telco Orange Hit by Cyber-Attack

ATC Ghana supports Girls-In-ICT Program

Basically, Instagram supports all kinds of images ( https://help.instagram.com/1631821640426723) but a square-shaped photo fits the best.

So, We have to resize the photo to a 1080 x 1080 pixels size.

Output File Size

There are multiple use cases are possible like

  1. The original photo is already square but smaller in size.
    Use case 1
  2. The original photo is a rectangle and smaller in size
    Use case 2-1

Use Case 2-1

  1. The original photo is already square but larger in size.
    Use case 3
  2. The original photo is a rectangle and larger in size.

Use case 4-1

So the idea here is to use the maximum space from the original image only but if there is an area remaining fill it with a color.

Use Case 4-2

We will use the Pillow (Python’s image manipulation library) to process the image. If not install use below command


pip install Pillow

from PIL import Image
import requests


def make_square(im, min_size=1080, fill_color=(0, 0, 0, 0)):
    x, y = im.size
    print("Original size "+str(x)+" X "+str(y))
    size = max(min_size, x, y)
    new_im = Image.new('RGB', (size, size), fill_color)    
    if(x > y):
        mod = size/x
        x = int(x * mod)
        y = int(y * mod)
    elif(x < y):
        mod = size/y
        x = int(x * mod)
        y = int(y * mod)

    new_im.paste(im.resize((x,y)), (int((size - x) / 2), int((size - y) / 2)))
    x, y = new_im.size
    print("New size "+str(x)+" X "+str(y))
    return new_im



def processImage(url):
    img = Image.open(requests.get(url, stream=True).raw)
    new_img = make_square(img)
    new_img.show()


processImage("https://images.pexels.com/photos/771742/pexels-photo-771742.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1")

Original Image:
Original Image

Resized Image:
Resized Image

It will return the squared image.

Happy Coding <3

Source: Ashutosh Sharma
Tags: Make image Instagram compatible using Python
ShareTweet

Get real time update about this post categories directly on your device, subscribe now.

Unsubscribe

Search

No Result
View All Result

Recent News

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025
ATC Ghana supports Girls-In-ICT Program

ATC Ghana supports Girls-In-ICT Program

April 25, 2023

About What We Do

itechnewsonline.com

We bring you the best Premium Tech News.

Recent News With Image

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025

Recent News

  • Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa July 29, 2025
  • French Telco Orange Hit by Cyber-Attack July 29, 2025
  • ATC Ghana supports Girls-In-ICT Program April 25, 2023
  • Vice President Dr. Bawumia inaugurates ICT Hub April 2, 2023
  • Home
  • InfoSec
  • Opinion
  • Africa Tech
  • Data Storage

© Copyright 2026, All Rights Reserved | iTechNewsOnline.Com - Powered by BackUPDataSystems

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

No Result
View All Result
  • Home
  • Tech
  • Africa Tech
  • InfoSEC
  • Data Science
  • Data Storage
  • Business
  • Opinion

© Copyright 2026, All Rights Reserved | iTechNewsOnline.Com - Powered by BackUPDataSystems

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
Go to mobile version