how to animate by color rotation only?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
luvaul
Posts: 3
Joined: 2016-08-18T17:51:06-07:00
Authentication code: 1151

how to animate by color rotation only?

Post by luvaul »

Hi all.

I'm trying to take a static RGB image and from it create an animated gif of 3 frames where the only thing that changes is the order of the color channels. https://www.youtube.com/watch?v=YthPDkV8BQk shows something like this being done, but it uses Photoshop and I'm wondering if it is possible with ImageMagick. Also the video uses more color "steps" (and therefore frames) than I need... I think it rotates around the color wheel 12 times before coming back to the start. I only need 3 steps/frames, so basically I want the image to start as RGB, change to BRG, and end with GBR.

> convert --version
Version: ImageMagick 6.7.8-9 2016-05-09 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

Thanks in advance for any suggestions,
Lance
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to animate by color rotation only?

Post by fmw42 »

What is your platform? What image do you want to use? Can you provide that? You can upload to some free hosting service and put the URL here. Is the whole image changing color or just a part of it?

Here is a simple example:

# create a red image

Code: Select all

convert -size 150x150 xc:red red.gif
Image

# copy it and convert to green, copy it and convert to blue, combine as animation

Code: Select all

convert -delay 100 red.gif \
\( -clone 0 -modulate 100,100,167 \) \
\( -clone 0 -modulate 100,100,233 \) \
-loop 0 -layers optimize hue_rotation_animation.gif
Image


Note the modulate B,S,H function has no change when Brightness, Saturation, and Hue are a each 100. Hue ranges from 100 to 300 to correspond with angles of 0 to 360.

So
hue of 120 => 100+(200*120/360) = 167
hue of 240 => 100+(200*240/360) = 233
luvaul
Posts: 3
Joined: 2016-08-18T17:51:06-07:00
Authentication code: 1151

Re: how to animate by color rotation only?

Post by luvaul »

Wow, thanks for such a quick reply! And thanks for your code snippet... that worked great :) The whole image is changing (just what I wanted).

One final question: I note that the final image has tripled in size (roughly) which is to be expected since there are now three frames in it. I was just curious if GIF had any clever way of performing hue rotation animations using just info (hue angles or whatever) stored in the header so the file didn't have to increase in size? This is more a matter of curiosity on my part than any requirement of the project I'm working on...

Cheers (and thanks again!),
Lance
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to animate by color rotation only?

Post by fmw42 »

Not that I know. GIF if pretty old and simple. But I do not know any image format that would do what you want.
luvaul
Posts: 3
Joined: 2016-08-18T17:51:06-07:00
Authentication code: 1151

Re: how to animate by color rotation only?

Post by luvaul »

No worries. Thanks for your help!
Lance
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to animate by color rotation only?

Post by fmw42 »

Perhaps it can be done in CSS and/or Javascript or HTML5????
Post Reply