Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

reversed colors png images.

by Anonymous Monk
on Dec 18, 2013 at 15:31 UTC ( #1067642=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi.I'm making an animated gif by using png images/files. But frequently the fore- and background colors get mixed up, for no reason. When i look at the images with a word-viewer f.e. the picture looks ok, but when I use it in an animation the colors get mixed up, making it impossible to make my animation. Please help. Best regards.

Replies are listed 'Best First'.
Re: reversed colors png images.
by taint (Chaplain) on Dec 18, 2013 at 17:37 UTC

    In addition to size (as BrowserUk already noted), you will also need to consider color -- color mapping, color pallet, and color index. Most importantly; the index must be the same for all images used within your animation. else you will not be able to attain a transparent background (if you intend one) and there will be pixelization(sp) which it appears you are describing. Easiest way to discover this info, is probably to open the three images in your image management software (gimp, photoshop, etc...), and look for these factors (compare them). Perhaps there's an "image info(rmation)" in the programs menu? I know the gimp has it, and I can't imagine the others wouldn't. If their not, you should be able to reduce the colors to that of the image with the least colors. There's usually "import" the other images into the one with the lowest color value. Which will "unify" the pallet for all three.


    Yes. What say about me, is true.
Re: reversed colors png images.
by Random_Walk (Prior) on Dec 18, 2013 at 15:33 UTC

    Please update your original node and tell us where Perl comes into this. Then add some code that will run and demonstrate your problem. Once you have done that there are plenty of Monks who will help you with pleasure.

    for more guidance see this node: How do I post a question effectively?


    Pereant, qui ante nos nostra dixerunt!

      I'm making an animated gif with perl and i'm using the gd module. I use the newFromPng method to import images. Then i'm working on an animation that looks like:

      use GD; $img = GD::Image->newFromPng('test1.png'); $img2 = GD::Image->newFromPng('test2.png'); $img3 = GD::Image->newFromPng('test3.png'); $data = $img->gifanimbegin(1,0); $data.=$img->gifanimadd(0,0,0,1); $data.=$img2->gifanimadd(0,0,0,1); $data.=$img3->gifanimadd(0,0,0,1); $data.=$img->gifanimend; binmode STDOUT; print $data;

      I can't provide code to demonstrate my problem.But my problem is that the image colors get mixed up, so the screen starts blinking.

        1. Are your 3 images all the same size?
        2. What is the logic for adding the same image twice with just 1 x 1/100th of a second delay each?
        3. Do you expect to see the animation of 3 images, displayed for 0.02, 0.01 & 0.01 seconds each respectively, to actually visibly move?

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        Have you tried gifanimadd(1,0,0,1)?
Re: reversed colors png images.
by Anonymous Monk on Dec 19, 2013 at 08:03 UTC

    It's working. I rebuild one image, this time setting the background pixels explicitely with the setPixel method, and it's fine now. Thank you.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1067642]
Approved by taint
and the shadows deepen...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2018-03-18 04:41 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (228 votes). Check out past polls.