top of page
  • scotteells

Content Managers Rejoice: Automating Tasks With AI (Pt. 2)

Welcome back. Let's expand the skillset and dive into the world of batch processing, image analysis and scheduling automation. Say goodbye to monotonous tasks, and let Python and ChatGPT do the heavy lifting. Ready?

A robot struggling with a task, atop a cylinder of files.

The Power of Batch Processing

In Part 1 we cover the basics of batch processing - image resizing, renaming etc - but we can accomplish multiple tasks in one go, all at the same time. Imagine having hundreds, or thousands, or ten of thousands of images that need to be resized to the same dimensions, renamed according to a specific format, and their metadata updated. Instead of editing each file individually, batch processing can take care of it in one fell swoop. So, let's learn to create a Python script to perform these operations in bulk. We'll enlist the help of Pillow for image resizing and pyexiv2 for metadata editing. And just as before, I'll recommend ChatGPT 4 over 3.5 to accomplish all the below. Oh, and one more time - don't forget to back up your files. Things can and will go horribly wrong on occasion.

Step 1: Articulating the Task for ChatGPT

Before we get coding, we need to make sure we are clear on our task. Let's say we want to resize all JPEG images in a directory to a width of 800px, preserving the aspect ratio, rename them according to a "fileN.jpg" format, and add a copyright notice to their metadata.

To ask ChatGPT for the relevant Python code, you could prompt it as follows:

"I want to create a Python3 script using the Pillow and pyexiv2 libraries that resizes all JPEG images in a directory to a width of 800 pixels while keeping the aspect ratio, renames the files in a "fileN.jpg" format where N is the sequence number, and adds a copyright notice to the image metadata. Please provide the necessary code."

  • ** Pro tip: On your Mac, open a finder window. Go to View > Show Path Bar. You can then click on the folder where you want the action to take place, and let ChatGPT write that directly into the code - one less step you have to take. Which also makes it easier if you need to have the code re-written to account for something you had not expected. Here's a detailed explanation if you are having issues.

Step 2: Incorporating ChatGPT’s Code

ChatGPT should provide you with the necessary Python code for the task. It would look something like the following:

Step 3: Running Your Python Script

Save this script in a .py file. Run it via Terminal by navigating to your script's directory and typing python3 And that's it. Your files are now resized, renamed, and have your copyright notice in their metadata.

Batch processing is a game changer in content management, saving you time and allowing you to focus on the more creative aspects of your work. For more info on processing images in Python with Pillow, check out this podcast.


Image Analysis In content management, imagery is king. Whether it's for a website refresh, social media campaign, or product catalog, high-quality, consistent imagery matters. But when you're dealing with hundreds, if not thousands, of images ensuring consistency can be tough. That's where image analysis comes in.

By leveraging Python libraries like OpenCV or Pillow, you can quickly sort through a massive pile of images and filter them based on various properties. Let's say you're launching a new website and you want all the images to have the same aspect ratio, or maybe you're creating a black-and-white photo series and need to filter out all colored images. Or possibly during a large asset migration, you'd like to sort images into certain categories before they are ingested into your system (if this is the case, for the love of god - back up your data, test the script on test assets and do a careful QA over the results). With Python and ChatGPT, these tasks are way easier.

Step 1: Defining the Task for ChatGPT

Let's set up a scenario. You want to filter out all images in a directory that are landscape-oriented (wider than they are tall) and have a predominantly blue color profile. Here's how you might ask ChatGPT to generate the appropriate Python code:

"Create a Python script using the Pillow and OpenCV libraries that filters out all landscape-oriented images in a directory and checks if the images are predominantly blue. Please provide the necessary code."

Step 2: Implementing ChatGPT’s Code

ChatGPT should provide a Python script similar to this:

What Else is Possible With Image Analysis?

  • Color Replacement: Find and replace a specific color in an image, handy for quick brand color updates.

  • Automatic Cropping: Crop images to a specific subject using object detection techniques. For example, you could auto-crop product photos to the product itself.

  • Image Compression: Analyze and automatically compress images that are above a certain file size without perceptible loss in visual quality.

  • Visual Search: Create a visual search engine that finds images in your database that are visually similar to a given image.

  • Face Detection: Identify images that contain faces, useful for privacy considerations or to separate portraits from other images. (Below you can see some of the limitations using something like Haar cascades (which is older technology)/OpenCV repository on GitHub as-is, which ChatGPT may recommend - it correctly identifies several faces, but not others, and also throws a couple false positives). There are steps you can take to improve this, or research and use another model entirely.

Some of the shortcoming of the facial recognition
Some of the shortcoming of Haar cascades for facial recognition

  • Text Extraction: Extract text from images using OCR (Optical Character Recognition) technology. This could help in transcribing text from memes, slides, or signs.

  • Duplicate Detection: Detect and remove duplicate images from your database, saving storage space.

  • Quality Check: Automatically reject images that fall below a certain quality threshold (blurry, too dark, etc.).

  • Semantic Segmentation: Separate images into sections based on what is present in the image (people, buildings, cars, etc.). This could be useful for content tagging and searchability.

  • Augmented Reality (AR) Effects: Add AR effects to an image based on its content, like adding a hat to all people in an image, or replacing the background, though, some of these actions have become very simple on a single image using tools like Generative Fill in Photoshop.

Note that many of these items will require pre-processing the images, some will take a deeper dive, and some are better handed off to a skilled engineer.

Image analysis is a powerful tool for content managers, turning potentially hours of manual work into a quick, automated process. The examples provided here are just scratching the surface of what's possible with Python and a bit of creativity.


Scheduling Automation

Ever wished you could make weekly or monthly tasks, like generating reports, happen without lifting a finger? Well, with Python, ChatGPT, and tools like cron, it's entirely possible. Grab your Mac and get started.

Why Scheduling Automation?

Think of scheduling automation as your trusty content management sidekick. It's there to take care of the tasks that need to happen regularly but don't necessarily need your personal touch. Whether it's generating weekly performance reports or organizing monthly assets, scheduling automation ensures these tasks happen on time, every time. And the best part? Once you've set it up, you can sit back and let it do its thing.

Step 1: Defining the Task for ChatGPT

Let's say you want to automate the process of resizing new images in a directory every week. Here's how you might ask ChatGPT to generate the appropriate Python code:

"I need to create a Python script using the Pillow library that resizes all new JPEG images in a directory to a width of 800 pixels, keeping the aspect ratio. This script should run once every week. Please provide the necessary code."

Step 2: Implementing ChatGPT’s Code

ChatGPT should provide you with the necessary Python code. Here's an example:

Step 3: Automating the Task with cron

Save the Python script in a .py file. To schedule this script to run once a week, we will use a tool called cron. Open Terminal and type "crontab -e" to edit your cron jobs. Add a new line like this:

This line tells cron to run your script every Sunday at midnight. Cron is not the most beautiful or intuitive interface to use - if you run into any issues, just ask ChatGPT what time and day you want it to run, and it will provide you with the correct prompt. You can also accomplish more complicated scheduling tasks by also using other apps such as Zapier, or IFTTT. Just include those in your scheduling prompt.

Things You Can Accomplish With Scheduling Automation

  1. Automated Backups: Schedule regular backups of your digital assets.

  2. Content Publishing: Automatically publish or remove content based on the schedule.

  3. Data Cleaning: Schedule regular cleanup of your digital assets to maintain consistency.

  4. Email Reports: Send automated weekly or monthly performance reports.

  5. Social Media Posts: Schedule regular posts to your social media platforms.

  6. Updating Digital Assets: Automatically update metadata of newly added assets.

  7. Content Archiving: Move old content to archive on a regular schedule.

  8. Content Refresh: Automatically refresh web content to keep it up-to-date.

  9. Automated Alerts: Send alerts for tasks that need human intervention.

  10. Maintenance Tasks: Schedule maintenance tasks during off-hours.

Scheduling automation is a powerhouse for content managers. It's like having an assistant who's always on time and never takes a day off.

With Python, ChatGPT, and a bit of initiative, you can automate a wide range of tasks and truly harness the power of modern content management. So keep exploring, keep questioning, and let the power of automation transform your content management game.



bottom of page