Results 1 to 6 of 6

Thread: HTML Signature Images Which Rotate

  1. #1
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    3

    Arrow Solved (But some cool code for you) - HTML Signature Images Which Rotate

    Good morning,
    I see a few threads about images in signatures, but they aren't quite what I need, and I don't want to bump old threads, so I thought it best to start my own.

    I have an HTML signature in Zimbra CS.

    I can add an image by file, and it uploads and embeds just fine.

    I can add an image by URL, and it downloads and embeds just fine.

    However, I do not want my image to be embedded; I want it to be linked to a remote file.

    Yes, I realize some software on the receivers' end will block this if I'm not an approved sender, but that's fine.

    Here's the scenario:

    I wrote a script which grabs current specials from our catalogue, generates a PNG image of the top 4 specials, and saves them to a PNG file on our web server. I want that image, featuring our top 4 specials, to be embedded in my Zimbra signature.

    The problem is, the image is updated daily by a cronjob (the file is re-generated), but Zimbra does not link to the file (it embeds the version of the file at the time it was added to my signature), so in a week, my signature will contain images of top specials from a week prior, meanwhile the file on the server itself contains all the new specials, each day.

    Is there a way I can have Zimbra link to an image via my signature rather than having it grab the image in its current state and embed it?

    Since there is no text-mode HTML editing feature on the ZCS signature editor, I'm stuck.

    I do indeed have access to SSH into the server if necessary, but would have to run whatever I do past my boss first.

    Thanks in advance for your help!

    Robbie
    Last edited by RobbieF; 03-28-2012 at 10:08 AM.

  2. #2
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    3

    Cool I may have been mistaken.



    Looks like Zimbra suddenly got the new image! While nice, I wonder why it didn't earlier (the cronjob ran a few hours ago and I was able to confirm the file was updated by browsing to it on our web server).

    Ah well.. probably moot, but I'll bump if I find I'm jumping the gun.

    Cheers,
    Robbie

  3. #3
    Join Date
    Jun 2011
    Location
    Caracas Venezuela
    Posts
    476
    Rep Power
    4

    Default

    Robbief, will you please to share your script?

    I think it's a great feature you made.

    ccelis.

  4. #4
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    3

    Lightbulb

    Hey ccelis5215,
    Well, it's kinda a custom thing so you'd have to know how to code in order to adapt it...

    Basically I created a PHP file on our web site (hidden to the world) which simply connects to the database and outputs 4 current products in a table, side by side, at a width of 640px.

    So then I use a cronjob on a Debian system with X11, PHP, imagemagick and wkhtmltopdf installed, and the cronjob calls this script:

    Code:
    <?php
    $url = 'https://mysite.com/location_of_the_php_file.php'; // the file you want to screenshot
    $filename = '/home/robbie/Scripts/signature'; // this is where I want it to save to. The folder 'Scripts' exists, the files 'signature.*' can exist (will be overwritten) but are generated the first time the script runs
    $command = "wkhtmltopdf $url $filename.pdf"; // convert the web site (table with products) to a PDF file
    exec($command, $output, $ret);
    if ($ret) {
        echo "error fetching screen dump\n";
        die;
    }
    
    $command = "convert -density 110 -depth 8 -quality 85 -trim $filename.pdf -append $filename.png"; // convert that PDF file to a PNG image (my signature), trim the whitespace and scale it down by about 25% (you can change density to 125 or so if you want it full size)
    exec($command, $output, $ret);
    if ($ret){
        echo "Error converting\n";
        die;
    }
     
    echo "$url converted to $filename.png\n";
    ?>
    Then a cronjob runs a few minutes later to actually upload the signature to the server... it runs the following sh script:
    Code:
    #!/bin/sh
    HOST='ftp.myserver.com'
    USER='myusername'
    PASSWD='mypassword'
    
    ftp -n $HOST <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD
    cd /where/to/save/file
    put /home/robbie/Scripts/signature.png ./signature.png
    quit
    END_SCRIPT
    exit 0
    Note that "/where/to/save/file" is an existing web-accessible folder on your FTP server. In my case, it's /domains/mydomain.com/images

    Also, you'll need to modify "/home/robbie/Scripts/signature.png" to reflect where you had your PHP file save the signature.

    So each day, the cron first generates the signature basically by downloading a screenshot of the web page (which is really just a table with 4 products), then it uploads that screenshot to the place on my web site where I want the signature. I then add the file's URL to my Zimbra signature.

    The cronjobs look like this:
    Code:
    # Signature
    0 9 * * * php /home/robbie/Scripts/daily_signature.php
    15 9 * * * /home/robbie/Scripts/daily_signature_upload.sh
    Notice how I'm running the PHP script without apache.

    Remember, the cron end of things requires an x11 system, so it won't run on a headless LAMP stack (unless it has the X dependencies installed... which I wouldn't recommend).

    Of course, you can use this for so many things...

    Hope that helps... someone.

    Robbie
    Last edited by RobbieF; 03-28-2012 at 06:31 AM. Reason: Added the PHP open / close just in case someone didn't know to do that...

  5. #5
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    3

    Exclamation

    NOTE - I have confirmed that Zimbra indeed is loading the images from the remote server, and the script is working great, so I've marked this as "solved", but will leave the above script in case anyone wants to play with it.

    Robbie

  6. #6
    Join Date
    Jun 2011
    Location
    Caracas Venezuela
    Posts
    476
    Rep Power
    4

    Default

    Thanks RobbieF, sure it's helps!

    ccelis.

Similar Threads

  1. Replies: 3
    Last Post: 03-06-2012, 08:30 AM
  2. HTML, CSS Background Images
    By derek-morton in forum General Questions
    Replies: 0
    Last Post: 05-24-2011, 12:43 AM
  3. [SOLVED] ZCS 7 Inline Signature Images
    By bobm in forum Administrators
    Replies: 1
    Last Post: 03-10-2011, 12:46 PM
  4. HTML Signature using HTML Web Client
    By Kidoucorp in forum Users
    Replies: 0
    Last Post: 01-05-2011, 07:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •