Page 1 of 1

how to animate by color rotation only?

Posted: 2016-08-18T18:40:11-07:00
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

Re: how to animate by color rotation only?

Posted: 2016-08-18T19:01:43-07:00
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

Re: how to animate by color rotation only?

Posted: 2016-08-18T19:34:26-07:00
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

Re: how to animate by color rotation only?

Posted: 2016-08-18T20:01:54-07:00
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.

Re: how to animate by color rotation only?

Posted: 2016-08-18T21:48:07-07:00
by luvaul
No worries. Thanks for your help!
Lance

Re: how to animate by color rotation only?

Posted: 2016-08-19T16:26:53-07:00
by fmw42
Perhaps it can be done in CSS and/or Javascript or HTML5????