Web gallery page which auto-updates - possible?

Discussion in 'UK Photography' started by Roger Moss, Jan 4, 2006.

  1. Roger Moss

    Roger Moss Guest

    I want to create a web page on which a single image changes each day -
    anyone know of a piece of code or an app which will allow me to upload a
    selection of, say 30 images and then leave it to effect the daily changes
    automatically?

    I can't always guarantee to be able to have a connection while travelling,
    so need to automate, if at all possible...

    Oh, and Happy 2006 to all!

    RM
     
    Roger Moss, Jan 4, 2006
    #1
    1. Advertisements

  2. Roger Moss

    Geoff Berrow Guest

    Message-ID: <dph1ka$fi7$> from "Roger Moss"
    Do you have PHP on your server?
    assuming you have images which are named 1.jpg, 2.jpg ... 31.jpg then
    include the following where you need your image and save the page with
    the extension .php

    <?php

    $img=date("j");
    print "<img src='$img.jpg' alt='Picture of the day'>";

    ?>
     
    Geoff Berrow, Jan 4, 2006
    #2
    1. Advertisements

  3. On Wed, 4 Jan 2006, Roger Moss wrote:

    RM> I want to create a web page on which a single image changes each day -
    RM> anyone know of a piece of code or an app which will allow me to upload a
    RM> selection of, say 30 images and then leave it to effect the daily changes
    RM> automatically?
    RM>
    RM> I can't always guarantee to be able to have a connection while travelling,
    RM> so need to automate, if at all possible...
    RM>

    I do this - in three places. The photo of me at the top right hand corner
    of my website @ http://www.clifford.ac appears to be alan.clifford.jpg but
    it changes every hour. Similary, the "about me" photo on
    http://uomograsso.blogspot.com changes every hour. Most fun is the photo
    on my Outlook out-of-office autoreply at work which contains a link to a
    file back on my webserver at home - having received the autoreply, if they
    look at it again after an hour or receive another autoreply, the photo has
    changed.

    Summary: Every hour a cron job runs a script that points
    alan.clifford.jpg to a new, real photo.


    Geeky details follow:

    On the webpage:

    <a href="./photo/me.links/index.html">
    <img align="bottom" src="./me/alan.clifford.jpg"
    alt="Alan Clifford" border=0 hspace=20></a>

    At the webserver, alan.clifford.jpg is a symbolic link pointing to an
    actual photo:

    lrwxrwxrwx 1 alan 14 2006-01-04 20:13 alan.clifford.jpg ->
    ../p4150714.jpg
    -rw-r--r-- 1 alan 6866 2006-01-04 20:13 dscn0348.jpg
    -rw-r--r-- 1 alan 7199 2006-01-04 19:13 p4190161.jpg
    -rw-r--r-- 1 alan 7652 2006-01-04 18:13 pc280014.jpg

    -rw-r--r-- 1 alan 6349 2006-01-04 05:13 pa231762.jpg
    -rw-r--r-- 1 alan 7040 2006-01-04 04:13 dscn0049.jpg
    -rw-r--r-- 1 alan 7861 2006-01-04 03:13 dscn0026.jpg
    -rw-r--r-- 1 alan 7414 2006-01-04 02:13 p4150714.jpg
    -rwxr--r-- 1 alan 1456 2005-12-03 00:37 alan.clifford.sh*


    alan.clifford.sh is a bash script that changes the link to point to
    another photo and updates time stamps:

    <-------- cut here --------------->
    #!/bin/bash
    # Makes a symbolic link to a .jpg file in the directory
    # passed in parameter 1.
    # When run again, points the link to the oldest .jpg

    MYDIRECTORY=${1:?
    Usage: $0 directory}


    cd ${MYDIRECTORY}
    if [ $? -ne 0 ]; then exit; fi
    echo ${MYDIRECTORY}

    PHOTO=alan.clifford.jpg
    echo ${PHOTO}
    # $PHOTO may not exist. Also makes it the newest.
    # if it is already a link, the source will be touched
    touch ${PHOTO}

    # this will eventually be the new photograph
    NEWPHOTO=${PHOTO}

    # echo
    for photo in ./*.jpg ./*.JPG
    do
    # echo "<${photo}>"
    if [ -f ${photo} ]; then
    # not a symbolic link
    # and not the same file
    # echo "hello 1"
    if [ ! -h ${PHOTO} ]; then
    if [ ! ${PHOTO} -ef ${photo} ]; then
    # echo "hello 2"
    NEWPHOTO=${photo}
    # ln -sfh ${photo} ${PHOTO}
    break
    fi
    else
    # point to the oldest file
    # echo "hello 3"
    # compare ages
    if [ ${photo} -ot ${NEWPHOTO} ]; then
    # echo "hello 4"
    NEWPHOTO=${photo}
    # echo ${NEWPHOTO}
    fi
    fi
    fi
    done

    if [ ! ${PHOTO} -ef ${NEWPHOTO} ]; then
    # echo "hello 5"
    ln -sf ${NEWPHOTO} ${PHOTO}
    echo ${NEWPHOTO}
    fi

    <-------- cut here --------------->

    The script is run with a crontab entry of:

    # update the website photo every hour at 13 minutes past
    # No email, log instead
    13 * * * * $HOME/photographs/me/alan.clifford.sh $HOME/photographs/me
    | /usr/bin/logger -t "alan.clifford.sh" 2>&1



    --
    Alan

    ( If replying by mail, please note that all "sardines" are canned.
    There is also a password autoresponder but, unless this a very
    old message, a "tuna" will swim right through. )
     
    Alan Clifford, Jan 4, 2006
    #3
  4. Roger Moss

    Stroller Guest

    I thought you had to be a "bona-fide" educational institution to get a
    domain.ac - I'm sure this was the case last time I looked at it (a
    couple of years ago) and now I find I've missed out on life.ac :(

    Stroller.
     
    Stroller, Jan 5, 2006
    #4
  5. Roger Moss

    Stu Carter Guest

    For .ac.uk yes, you must be an ACademic institution. However, .ac is the
    top-level domain for the Ascension Islands and I guess they've decided
    like Tuvalu (.tv) and Cristmas Island (.cx) to make a little cash out of
    their registry for allcomers.


    Cheers,

    Stu

    ObPhoto: I'm hoping to begin some 'people photography' this weekend. That
    involves approaching strangers. Wish me luck! :)
     
    Stu Carter, Jan 5, 2006
    #5
  6. Roger Moss

    Stroller Guest

    Yeah, I know.
    When I looked at this they would issue anyone .com.ac but were a little
    more restrictive about yourname.ac.

    Stroller.
     
    Stroller, Jan 5, 2006
    #6
  7. On Thu, 5 Jan 2006, Stu Carter wrote:

    SC> On Thu, 5 Jan 2006, Stroller wrote:
    SC>
    SC> > I thought you had to be a "bona-fide" educational institution to get a
    SC> > domain.ac - I'm sure this was the case last time I looked at it (a
    SC> > couple of years ago) and now I find I've missed out on life.ac :(
    SC>
    SC> For .ac.uk yes, you must be an ACademic institution. However, .ac is the
    SC> top-level domain for the Ascension Islands and I guess they've decided like
    SC> Tuvalu (.tv) and Cristmas Island (.cx) to make a little cash out of their
    SC> registry for allcomers.
    SC>

    This has strolled a tad off topic - I hope others don't mind. But, yes,
    ..ac do promote themselves as the academic domain (see rule 3.1 An
    applicant may reside in any legal jurisdiction and shall have obtained a
    professional or academic qualification, or hold valid membership of an
    Institute or Trade Association). I chose it because my initials are ac -
    an expensive whim compared to .org, .net etc. They wouldn't let me have
    @ac.ac though, which I thought was a bit mean.

    Swaying marginally back towards photography, you should be looking at .eu
    ready for April. Unfortunately, a couple of companies reckon they have a
    prior right on photography.eu and 21 for photo.eu, although the same
    company seems to have applied several times. DepthOfField.eu hasn't been
    applied for yet, nor DoF.eu. Nor megapixel.eu

    http://www.whois.eu/whois/GetDomainStatus.htm

    --
    Alan

    ( If replying by mail, please note that all "sardines" are canned.
    There is also a password autoresponder but, unless this a very
    old message, a "tuna" will swim right through. )
     
    Alan Clifford, Jan 5, 2006
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.