Skip to content
G GBTI

Using Python to animate the hue of an image

  • devops
  • frameworks
  • python
Using Python to animate the hue of an image

Have you ever wanted to animate the hue of an image? We did recently but we didn’t quite know how so we developed an application using python to help us do just that.

Before we get started, though, let’s take a moment to learn what exactly is hue?

Hue, in the context of color theory, refers to the attribute of a color that enables us to classify it as red, blue, green, or any other color in the spectrum. It represents the pure spectrum colors found on the color wheel, which range from red through to violet, plus magenta.

So to shift the hue is to change it’s color to a different one corresponding to a 360 degree color wheel/spectrum.

Red, green, and blue are often placed at 120-degree intervals on the wheel (0° for red, 120° for green, 240° for blue). Colors like cyan, magenta, and yellow are located at the halfway points between the primary colors. For example, cyan is at 180°, halfway between green (120°) and blue (240°).

Animating Hue in a still image

So to recap, we knew if we could achieve this, it would look great, to say the least. And that was good enough for us to get started.

To demonstrate our progress we first used DALL-E to generate a colorful image, with jungles, and dinosaurs, and the Python logo because we would be using the Python coding language to generate the animation:

A graphical image with the python logo in the center that is surrounded by jungle and dinosaurs, both land creatures and flying creatures. Bright colors. It will look very good animated.

We’ve used Dalle to generate colorful image with dinosaurs and the python logo.

Now that we’ve chosen a very colorful base image to begin with, we run it through code base with an instruction to animate from -180 to 180 degrees over 30 frames and a few minutes later we have generated this mp4:

We also generated the animation as a gif. The MP4, though, is under 2mb and loads nearly instantly on this blog post where we have set it to autoplay and loop (autoplay may not work on mobile).

The gif, however, being 30 frames, at the size of 1024 x 1024, comes out to be a whopping 18mb.

Py Animate Hue – How to Download and Features

Py Animate Hue has been released as open source software and is available on GitHub to download.

https://github.com/gbti-labs/py-animate-hue

In addition to Hue, we coded in the ability to animate Brightness as well as Contrast.

In the future we may add more support for different animation features, but for now, please feel free to star our repository, fork it if you like, and join our discord and socials to follow more open source opportunities.

Thanks for reading!

If you like our content, please consider following us! If you like our free open-source assets, please give them a github star. We’re also happy to have lurkers on our Discord community where we manage our syndication network and curate together.

A creator co-op, powered by Git

Join the GBTI Network

The GBTI Network is a creator co-op. Members showcase their work, write articles, share in co-op profits, and meet in weekly coaching calls with the community.

Publish your profile, blog posts, products, and prompts
Share in co-op profits
Join weekly coaching calls with the community

A 90-day limited-access trial lets you evaluate the community before you pay. Paid membership is $150 per year and unlocks your public presence on the network: your profile, blog, products, and prompts.

0 Comments

No comments yet. Be the first. Members comment from the GBTI local client, where comments are submitted as pull requests and auto-published for paid members.

Become a member

Members write comments from the GBTI client or browser extension. Become a member to join the conversation.

Written by

GBTI Network

Published 22nd Jan 2024

View profile
Contribution history
No tracked contributions yet. A member who improves this article through an accepted pull request earns a share of the revenue it generates.

Imported from the legacy WordPress site, so the earliest edits live there. Everything since is tracked here as member contributions.

Full history on GitHub Spotted something? Become a member to contribute.

Related posts

Sign in with the GBTI extension

Signing in and publishing happen through the free GBTI browser extension. It keeps your GitHub sign-in on your own machine and lets you edit and publish in place.

The Chrome Web Store listing is coming soon. For now, the download page walks you through loading it as an unpacked extension.