Category: Win32
Author/Contact Info Koosemose
Description:

WallFortune simply generates a random fortune and puts in the upper right of your wallpaper.

This is just a little script I worked up for use on my own computer, and thought I would share it, so I made a few alterations so that anyone could use it.

note: It does not alter the original image, not only does it save the altered image under a different name, but also saves a copy of the original. (Both in a folder named images in the directory the script was ran from)

Thanks to: bbfu from whom I took the code to change current wallpaper, and also the same code inspired me to start digging around for other uses of Win32::API (particularly the bit that retreieves the current wallpaper.
bart and castaway for directing me to some sources for API reference
BastardOperator from whom I took the fortune generating sniplet for those without fortune
The makers of fortuneMod, from whom I grabbed some random fortunes for use in the inline fortune generation

#!/usr/bin/perl

use strict;
use warnings;
use Image::Magick;
use Win32::API;


use constant MAX_PATH => 120 ;
use constant SPI_GETDESKWALLPAPER => 115;
use constant SPI_SETDESKWALLPAPER  => 20;
use constant SPIF_UPDATEANDSENDINI => 3;
use constant NULL                  => 0;

# if you wish to use a different font or this isn't the proper path to
+ your fonts
#    then just simply change the value of this variable
my $font = 'C:\\windows\\fonts\\arial.ttf';
# Retreieve name and path of current wallpaper

   my $syspinf = Win32::API->new('user32','SystemParametersInfo', ['I'
+,'I','P','I'], 'I')
     or die "Could not import function.\n";

   # SPI_GETDESKWALLPAPER insists that the variable passed to it must 
+already have enough
   #   space in it to contain it's return value, so this is the quicke
+st way I know
   #   of to fill one up 
      my $wallpaper = "*" x 120;

   $syspinf->Call(SPI_GETDESKWALLPAPER, 120, $wallpaper,0);
   $wallpaper  =~ s/\*//g;
   my @wallpaper = (split /\\/ , $wallpaper);
   my $wallpaperfile = pop @wallpaper;

   # Quick and dirty method to insure that we don't add text to an ima
+ge that already has it
   $wallpaperfile  =~ s/^MOD//;
   $wallpaper = (join "\\" , @wallpaper,$wallpaperfile);

# Generate fortune to be placed on the wallpaper

#   Uncomment this section if you by chance have a functional version 
+of fortune
#   my @text =split /"\n"/,`fortune -s`;
#   my $text = join ("\n",@text);
#   $text =~ s/\t//g;

#   And here's the section for everyone else (Comment it out if you do
+ have fortune
   my $text = "";
   $/ = "%%\n";
   rand($.) < 1 && chomp($text = $_) while(<DATA>);
   $text =~ s/\t//g;

# A quick check to see if the directory for saving modified wallpapers
+ is present
#    and create it if it isn't
   if (!(-e "images" && -d "images"))
      {
      mkdir "images";
      }

# And now for imagefying the text and slapping it onto the background 
+image

   my $textimg = Image::Magick->new;
   my $newwallpaperimg = Image::Magick->new;
   $textimg->Set(size=>'500x500');
   $textimg->ReadImage('null:none');
   $newwallpaperimg->ReadImage($wallpaper);

   # Gotta make certain there's a copy of the original saved too
   $newwallpaperimg->Write("images\\".$wallpaperfile);

$textimg->Annotate(y=>+14,x=>+4, gravity=>'NorthEast', font=>$font, po
+intsize=>12, 

antialias=>'true', fill=>'none', stroke=>'#3cc0c5', text=>$text);

   $newwallpaperimg->Composite(image=>$textimg, compose=>'over', gravi
+ty=>'NorthEast');

# And finally the new composited image is saved and set to be the wall
+paper
   $newwallpaperimg->Write('images\\MOD'.$wallpaperfile);
   # The image is saved with a prefix for the identification of alread
+y modified
   #    files checked earlier in the script
   $syspinf->Call(SPI_SETDESKWALLPAPER, 0, 'images\\MOD'.$wallpaperfil
+e, 
      SPIF_UPDATEANDSENDINI);


undef $textimg;
undef $newwallpaperimg;



__END__
A clash of doctrine is not a disaster -- it is an opportunity.
%%
A dream will always triumph over reality, once it is given the chance.
        -- Stanislaw Lem
%%
A lifetime isn't nearly long enough to figure out what it's all about.
%%
A priest advised Voltaire on his death bed to renounce the devil. 
Replied Voltaire, "This is no time to make new enemies."
%%
A thing is not necessarily true because a man dies for it.
        -- Oscar Wilde, "The Portrait of Mr. W.H."
%%
All hope abandon, ye who enter here!
        -- Dante Alighieri
%%
All of the true things I am about to tell you are shameless lies.
        -- The Book of Bokonon / Kurt Vonnegut Jr.
%%
An idea is not responsible for the people who believe in it.
%%
At the end of your life there'll be a good rest, and no further activi
+ties
are scheduled.
%%
Beauty is one of the rare things which does not lead to doubt of God.
        -- Jean Anouilh
%%
By protracting life, we do not deduct one jot from the duration of dea
+th.
        -- Titus Lucretius Carus
%%
Catharsis is something I associate with pornography and crossword puzz
+les.
        -- Howard Chaykin
%%
Chance is perhaps the work of God when He did not want to sign.
        -- Anatole France
%%
Circumstances rule men; men do not rule circumstances.
        -- Herodotus
%%
Coincidences are spiritual puns.
        -- G.K. Chesterton
%%
Death is a spirit leaving a body, sort of like a shell leaving the nut
+ behind.
        -- Erma Bombeck
%%
Death is God's way of telling you not to be such a wise guy.
%%
Death is life's way of telling you you've been fired.
        -- R. Geis
%%
Death is Nature's way of recycling human beings.
%%
Death is nature's way of saying `Howdy'.
%%
Death is nature's way of telling you to slow down.
%%
Depart not from the path which fate has assigned you.
%%
Disease can be cured; fate is incurable.
        -- Chinese proverb
%%
Ditat Deus.
    [God enriches]
%%
Do not believe in miracles -- rely on them.
%%
Do not take life too seriously; you will never get out of it alive.
%%
Do what you can to prolong your life, in the hope that someday you'll
learn what it's for.
%%
Do your part to help preserve life on Earth -- by trying to preserve y
+our own.
%%
Don't abandon hope.  Your Captain Midnight decoder ring arrives tomorr
+ow.
%%
Don't abandon hope: your Tom Mix decoder ring arrives tomorrow.
%%
Don't go to bed with no price on your head.
        -- Baretta
%%
Don't have good ideas if you aren't willing to be responsible for them
+.
%%
Don't kid yourself.  Little is relevant, and nothing lasts forever.
%%
Don't let people drive you crazy when you know it's in walking distanc
+e.
%%
Don't make a big deal out of everything; just deal with everything.
%%
Don't stop to stomp ants when the elephants are stampeding.
%%
Don't take life seriously, you'll never get out alive.
%%
Down with categorical imperative!
%%
Due to circumstances beyond your control, you are master of your fate
and captain of your soul.
%%
During the voyage of life, remember to keep an eye out for a fair wind
+; batten
down during a storm; hail all passing ships; and fly your colors proud
+ly.
%%
Dying is one of the few things that can be done as easily lying down.
        -- Woody Allen
%%
Each man is his own prisoner, in solitary confinement for life.
%%
Each of us bears his own Hell.
        -- Publius Vergilius Maro (Virgil)
%%
Either I'm dead or my watch has stopped.
        -- Groucho Marx's last words
%%
Even the best of friends cannot attend each other's funeral.
        -- Kehlog Albran, "The Profit"
%%
Everything ends badly.  Otherwise it wouldn't end.
%%
Everything in this book may be wrong.
        -- Messiah's Handbook : Reminders for the Advanced Soul
%%
Everything is possible.  Pass the word.
        -- Rita Mae Brown, "Six of One"
%%
Execute every act of thy life as though it were thy last.
        -- Marcus Aurelius
%%
Expansion means complexity; and complexity decay.
%%
Facts are the enemy of truth.
        -- Don Quixote
%%
Fain would I climb, yet fear I to fall.
        -- Sir Walter Raleigh
%%
Faith goes out through the window when beauty comes in at the door.
%%
Faith is under the left nipple.
        -- Martin Luther
%%
Fill what's empty, empty what's full, scratch where it itches.
        -- Alice Roosevelt Longworth
%%
For fast-acting relief, try slowing down.
%%
For good, return good.
For evil, return justice.
%%
For your penance, say five Hail Marys and one loud BLAH!
%%
Force has no place where there is need of skill.
        -- Herodotus
%%
From listening comes wisdom and from speaking repentance.
%%
From the cradle to the coffin underwear comes first.
        -- Bertolt Brecht
%%
Generally speaking, the Way of the warrior is resolute acceptance of d
+eath.
        -- Miyamoto Musashi, 1645
%%
Getting into trouble is easy.
        -- D. Winkel and F. Prosser
%%
Getting there is only half as far as getting there and back.
%%
Given a choice between grief and nothing, I'd choose grief.
        -- William Faulkner
%%
God grant us the serenity to accept the things we cannot change, coura
+ge to
change the things we can, and wisdom to know the difference.
%%
God instructs the heart, not by ideas, but by pains and contradictions
+.
        -- De Caussade
%%
God is the tangential point between zero and infinity.
        -- Alfred Jarry
%%
God made everything out of nothing, but the nothingness shows through.
        -- Paul Valery
%%
Good-bye.  I am leaving because I am bored.
        -- George Saunders' dying words
%%
Goodbye, cool world.
%%
Got a dictionary?  I want to know the meaning of life.
%%
Great acts are made up of small deeds.
        -- Lao Tsu
%%
Happiness is having a scratch for every itch.
        -- Ogden Nash
%%
Happiness is just an illusion, filled with sadness and confusion.
%%
Happiness isn't having what you want, it's wanting what you have.
%%
Happiness isn't something you experience; it's something you remember.
        -- Oscar Levant
%%
Having the fewest wants, I am nearest to the gods.
        -- Socrates
%%
He has shown you, o man, what is good.  And what does the Lord ask of 
+you,
but to do justice, and to love kindness, and to walk humbly before you
+r God?
%%
He is truly wise who gains wisdom from another's mishap.
%%
He knows not how to know who knows not also how to unknow.
        -- Sir Richard Burton
%%
He that composes himself is wiser than he that composes a book.
        -- B. Franklin
%%
He who knows not and knows that he knows not is ignorant.  Teach him.
He who knows not and knows not that he knows not is a fool.  Shun him.
He who knows and knows not that he knows is asleep.  Wake him.
%%
He who knows that enough is enough will always have enough.
        -- Lao Tsu
%%
He who knows, does not speak.  He who speaks, does not know.
        -- Lao Tsu
%%
Here is a test to find whether your mission on earth is finished:
if you're alive, it isn't.
%%
I am not afraid of tomorrow, for I have seen yesterday and I love toda
+y.
        -- William Allen White
%%
I hate dying.
        -- Dave Johnson
%%
I have often regretted my speech, never my silence.
        -- Publilius Syrus
%%
I have seen the future and it is just like the present, only longer.
        -- Kehlog Albran, "The Profit"
%%
I hope you're not pretending to be evil while secretly being good.
That would be dishonest.
%%
I just forgot my whole philosophy of life!!!
%%
If a man has a strong faith he can indulge in the luxury of skepticism
+.
        -- Friedrich Nietzsche
%%
If something has not yet gone wrong then it would ultimately have been
beneficial for it to go wrong.
%%
If the master dies and the disciple grieves, the lives of both have
been wasted.
%%
If the path be beautiful, let us not ask where it leads.
        -- Anatole France
%%
If we do not change our direction we are likely to end up where we are
+ headed.
%%
If we don't survive, we don't do anything else.
        -- John Sinclair
%%
If you can survive death, you can probably survive anything.
%%
If you find a solution and become attached to it, the solution may bec
+ome
your next problem.
%%
If you fool around with something long enough, it will eventually brea
+k.
%%
If you have to hate, hate gently.
%%
If you have to think twice about it, you're wrong.
%%
If you keep anything long enough, you can throw it away.
%%
If you live long enough, you'll see that every victory turns into a de
+feat.
        -- Simone de Beauvoir
%%
If you only have a hammer, you tend to see every problem as a nail.
        -- Maslow
%%
If you put it off long enough, it might go away.
%%
If you refuse to accept anything but the best you very often get it.
%%
If you wait long enough, it will go away... after having done its dama
+ge.
If it was bad, it will be back.
%%
If you want divine justice, die.
        -- Nick Seldon
%%
If your aim in life is nothing, you can't miss.
%%
Illusion is the first of all pleasures.
        -- Voltaire
%%
Immortality -- a fate worse than death.
        -- Edgar A. Shoaff
%%
In order to discover who you are, first learn who everybody else is;
you're what's left.
%%
In order to live free and happily, you must sacrifice boredom.
It is not always an easy sacrifice.
%%
In spite of everything, I still believe that people are good at heart.
        -- Ann Frank
%%
In the long run we are all dead.
        -- John Maynard Keynes
%%
In the next world, you're on your own.
%%
Instead of loving your enemies, treat your friends a little better.
        -- Edgar W. Howe
%%
It does not do to leave a live dragon out of your calculations.
%%
It is Fortune, not Wisdom, that rules man's life.
%%
It is said that the lonely eagle flies to the mountain peaks while the
+ lowly
ant crawls the ground, but cannot the soul of the ant soar as high as 
+the eagle?
%%
It is through symbols that man consciously or unconsciously lives, wor
+ks
and has his being.
        -- Thomas Carlyle
%%
It will be advantageous to cross the great stream ... the Dragon is on
the wing in the Sky ... the Great Man rouses himself to his Work.
%%
It's easier to take it apart than to put it back together.
        -- Washlesky
%%
It's hard to drive at the limit, but it's harder to know where the lim
+its are.
        -- Stirling Moss
%%
It's not reality that's important, but how you perceive things.
%%
    "It's today!" said Piglet.
    "My favorite day," said Pooh.
%%
It's very inconvenient to be mortal -- you never know when everything 
+may
suddenly stop happening.
%%
Just remember, wherever you go, there you are.
        -- Buckaroo Bonzai
%%
Kindness is the beginning of cruelty.
        -- Muad'dib [Frank Herbert, "Dune"]
%%
Let us not look back in anger or forward in fear, but around us in awa
+reness.
        -- James Thurber
%%
Life can be so tragic -- you're here today and here tomorrow.
%%
Life exists for no known purpose.
%%
Life is a grand adventure -- or it is nothing.
        -- Helen Keller
%%
Life is knowing how far to go without crossing the line.
%%
Life is like a 10 speed bicycle.  Most of us have gears we never use.
        -- C. Schultz
%%
Life is like a sewer.  What you get out of it depends on what you put 
+into it.
        -- Tom Lehrer
%%
Life is the childhood of our immortality.
        -- Goethe
%%
Life is the living you do, Death is the living you don't do.
        -- Joseph Pintauro
%%
Life is the urge to ecstasy.
%%
Life may have no meaning, or, even worse, it may have a meaning of whi
+ch
you disapprove.
%%
Life sucks, but death doesn't put out at all.
        -- Thomas J. Kopp
%%
Living in the complex world of the future is somewhat like having bees
live in your head.  But, there they are.
%%
Loneliness is a terrible price to pay for independence.
%%
Man's reach must exceed his grasp, for why else the heavens?
%%
Murphy was an optimist.
%%
Murphy's Law is recursive.  Washing your car to make it rain doesn't w
+ork.
%%
Music in the soul can be heard by the universe.
        -- Lao Tsu
%%
My theology, briefly, is that the universe was dictated but not signed
+.
        -- Christopher Morley
%%
Ninety percent of everything is crap.
        -- Theodore Sturgeon
%%
No matter where I go, the place is always called "here".
%%
No use getting too involved in life -- you're only here for a limited 
+time.
%%
Nobody ever ruined their eyesight by looking at the bright side of som
+ething.
%%
Nonsense and beauty have close connections.
        -- E.M. Forster
%%
Normal times may possibly be over forever.
%%
Not every question deserves an answer.
%%
Nothing in life is to be feared.  It is only to be understood.
%%
Nothing is but what is not.
%%
Nothing is ever a total loss; it can always serve as a bad example.
%%
Nothing is so firmly believed as that which we least know.
        -- Michel de Montaigne
%%
Nothing matters very much, and few things matter at all.
        -- Arthur Balfour
%%
Once the toothpaste is out of the tube, it's hard to get it back in.
        -- H.R. Haldeman
%%
Once you've tried to change the world you find it's a whole bunch easi
+er
to change your mind.
%%
One learns to itch where one can scratch.
        -- Ernest Bramah
%%
One meets his destiny often on the road he takes to avoid it.
%%
One monk said to the other, "The fish has flopped out of the net! How 
+will it
live?" The other said, "When you have gotten out of the net, I'll tell
+ you."
%%
Only that in you which is me can hear what I'm saying.
        -- Baba Ram Dass
%%
Paradise is exactly like where you are right now ... only much, much b
+etter.
        -- Laurie Anderson
%%
Perhaps the biggest disappointments were the ones you expected anyway.
%%
Philosophy will clip an angel's wings.
        -- John Keats
%%
Push where it gives and scratch where it itches.
%%
Reality always seems harsher in the early morning.
%%
Reality does not exist -- yet.
%%
Reality is bad enough, why should I tell the truth?
        -- Patrick Sky
%%
Reality is for people who lack imagination.
%%
Reality is just a convenient measure of complexity.
        -- Alvy Ray Smith
%%
Reality is just a crutch for people who can't handle science fiction.
%%
Reality is nothing but a collective hunch.
    -- Lily Tomlin
%%
"Reality is that which, when you stop believing in it, doesn't go away
+".
        -- Philip K. Dick
%%
Rule of Life #1 -- Never get separated from your luggage.
%%
Seeing is believing.  You wouldn't have seen it if you hadn't believed
+ it.
%%
So little time, so little to do.
        -- Oscar Levant
%%
Sometimes even to live is an act of courage.
        -- Seneca
%%
Sometimes you get an almost irresistible urge to go on living.
%%
That that is is that that is not is not.
%%
The absurd is the essential concept and the first truth.
        -- A. Camus
%%
The best you get is an even break.
        -- Franklin Adams
%%
"The chain which can be yanked is not the eternal chain."
        -- G. Fitch
%%
The chief cause of problems is solutions.
        -- Eric Sevareid
%%
The chief danger in life is that you may take too many precautions.
        -- Alfred Adler
%%
The days are all empty and the nights are unreal.
%%
The door is the key.
%%
The farther you go, the less you know.
        -- Lao Tsu, "Tao Te Ching"
%%
The final delusion is the belief that one has lost all delusions.
        -- Maurice Chapelain, "Main courante"
%%
The first requisite for immortality is death.
        -- Stanislaw Lem
%%
The greatest griefs are those we cause ourselves.
        -- Sophocles
%%
The longest part of the journey is said to be the passing of the gate.
        -- Marcus Terentius Varro
%%
The major sin is the sin of being born.
        -- Samuel Beckett
%%
The more you complain, the longer God lets you live.
%%
The moss on the tree does not fear the talons of the hawk.
%%
The only difference between a rut and a grave is their dimensions.
%%
The price of success in philosophy is triviality.
        -- C. Glymour.
%%
The questions remain the same.  The answers are eternally variable.
        -- Damon Runyon
%%
The savior becomes the victim.
%%
The soul would have no rainbow had the eyes no tears.
%%
The state of innocence contains the germs of all future sin.
        -- Alexandre Arnoux, "Etudes et caprices"
%%
The truth is rarely pure, and never simple.
        -- Oscar Wilde
%%
The truth is what is; what should be is a dirty lie.
        -- Lenny Bruce
%%
The truth of a thing is the feel of it, not the think of it.
        -- Stanley Kubrick
%%
The truth you speak has no past and no future.  It is, and that's all 
+it
needs to be.
%%
There are no accidents whatsoever in the universe.
        -- Baba Ram Dass
%%
There are no winners in life, only survivors.
%%
There is more to life than increasing its speed.
        -- Mahatma Gandhi
%%
There is no comfort without pain; thus we define salvation through suf
+fering.
        -- Cato
%%
There is no cure for birth and death other than to enjoy the interval.
        -- George Santayana
%%
There is no sin but ignorance.
        -- Christopher Marlowe
%%
There's only one everything.
%%
To get something clean, one has to get something dirty.
To get something dirty, one does not have to get anything clean.
%%
To give happiness is to deserve happiness.
%%
To give of yourself, you must first know yourself.
%%
To have died once is enough.
        -- Publius Vergilius Maro (Virgil)
%%
To lead people, you must follow behind.
        -- Lao Tsu
%%
Truth has no special time of its own.  Its hour is now -- always.
        -- Albert Schweitzer
%%
Truth is hard to find and harder to obscure.
%%
Waste not fresh tears over old griefs.
        -- Euripides
%%
We can embody the truth, but we cannot know it.
        -- Yates
%%
We have nowhere else to go... this is all we have.
        -- Margaret Mead
%%
We have only two things to worry about:  That things will never get
back to normal, and that they already have.
%%
We have reason to be afraid.  This is a terrible place.
        -- John Berryman
%%
We're all in this alone.
        -- Lily Tomlin
%%
Well, you know, no matter where you go, there you are.
        -- Buckaroo Banzai
%%
What does not destroy me, makes me stronger.
        -- Nietzsche
%%
What makes the universe so hard to comprehend is that there's nothing
to compare it with.
%%
What sane person could live in this world and not be crazy?
        -- Ursula K. LeGuin
%%
What we Are is God's gift to us.
What we Become is our gift to God.
%%
Whatever occurs from love is always beyond good and evil.
        -- Friedrich Nietzsche
%%
Whatever you do will be insignificant, but it is very important that y
+ou do it.
        -- Gandhi
%%
When it's dark enough you can see the stars.
        -- Ralph Waldo Emerson,
%%
When the speaker and he to whom he is speaks do not understand, that i
+s
metaphysics.
        -- Voltaire
%%
When the wind is great, bow before it;
when the wind is heavy, yield to it.
%%
When you die, you lose a very important part of your life.
        -- Brooke Shields
%%
Who does not trust enough will not be trusted.
        -- Lao Tsu
%%
Wisdom is knowing what to do with what you know.
        -- J. Winter Smith
%%
Wisdom is rarely found on the best-seller list.
%%
With listening comes wisdom, with speaking repentance.
%%
Yes, but which self do you want to be?
%%
You can always pick up your needle and move to another groove.
        -- Tim Leary
%%
You can get *anywhere* in ten minutes if you drive fast enough.
%%
You can never tell which way the train went by looking at the tracks.
%%
You can no more win a war than you can win an earthquake.
        -- Jeannette Rankin
%%
You can observe a lot just by watching.
        -- Yogi Berra
%%
You can only live once, but if you do it right, once is enough.
%%
You can't get there from here.
%%
You can't mend a wristwatch while falling from an airplane.
%%
You can't push on a string.
%%
You can't run away forever,
But there's nothing wrong with getting a good head start.
        -- Jim Steinman, "Rock and Roll Dreams Come Through"
%%
"You can't survive by sucking the juice from a wet mitten."
        -- Charles Schulz, "Things I've Had to Learn Over and
           Over and Over"
%%
You can't take it with you -- especially when crossing a state line.
%%
You climb to reach the summit, but once there, discover that all roads
lead down.
        -- Stanislaw Lem, "The Cyberiad"
%%
You have all eternity to be cautious in when you're dead.
        -- Lois Platford
%%
You have to run as fast as you can just to stay where you are.
If you want to get anywhere, you'll have to run much faster.
        -- Lewis Carroll
%%
You will always find something in the last place you look.
%%
Your happiness is intertwined with your outlook on life.
%%
Your mind understands what you have been taught; your heart, what is t
+rue.
%%
Your picture of the world often changes just before you get it into fo
+cus.
%%
Your wig steers the gig.
        -- Lord Buckley
%%
Replies are listed 'Best First'.
adding some code... win-Wallpaper shifter!
by chanio (Priest) on Jan 19, 2004 at 04:24 UTC
    Hi, I got inspired on this code to add something that would also change the wallpaper from a random list in a directory:)

    You should copy this code between the last constant definition and the next comment (#if you wish to use...)

    ## ***************** the SHIFTER ******************************* ## CHANGE THE DESKTOP BACKGROUND IMAGE... # dirIni = path to the directory where I have all the pictures to sor +t and choose one... my ($dirIni)='C:\Program files\Pictures\ImageCatcher'; # dirDesti= where I must record the new picture to write on it my ($dirDesti)='C:\Perl\guiones\images\Wallpaper1.bmp'; # tipos = valid image extensions of my pictures my ($tipos)= '\.jpg|\.gif|\.bmp|\.png|.\tif'; ##sort a list of valid images and return one with its complete path #sub nvaImagen { my (@ims); chdir($dirIni); opendir(DIR,$dirIni) or die("Cant open directory $dirIni $!"); ## grep filters & creates an array of valid pictures @ims = grep { $_ = "$dirIni/$_" if (/$tipos/ && -f "$dirIni/$_") ; $_ if (/$tipos/ && -f "$_"); } readdir(DIR); ##read every file closedir(DIR); ## the lotery... my ($ete)= int rand($#ims + .9999) if (@ims); my ($ima)= $ims[$ete] if ($ete && @ims); print "$ete - $ima\n"; ## checking the result ## reading the new image... my ($imobj, $er)=(Image::Magick->new,''); $er = $imobj->read($ima) if ($ima); die ("Error reading $ima [Img-Mgk] says: $er $!") if ($er); ## standarize an image size with IM $imobj->Resize(width=>800, height=>600, blur=>1); ## write the new image over the same old one $imobj->Write($dirDesti); } ## **********************/ the SHIFTER **************************
    Before using this new code, you should try the previous code, and see if it works ok. Then add this new part and call it when you start your system. Works nice, but might need some adjustments...

    You should change the directories and of course, the image name that is being displayed. This last one might not need to be changed if you have tryied the previous original code.

    There is also a regex filter list of image file extensions that you might need to add/modify. It doesn't matter the extension since Image::Magick does the conversion to .BMP.

    Please, read some info about how you might need to fine-tune Image::Magick on Windows (it is not that easy, but it works if you follow the recipy).

    Thank you Koosemose for your inspiration!