Results 1 to 10 of 10

Thread: Delivering an image through PHP

  1. #1
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181

    Delivering an image through PHP

    I need to be able to cause a php file to deliver a "dynamic" image kind of like you see from vBulletin and web bugs. What I want to do is use a JavaScript to write in a web bug that contains screen resolution information (e.g. webbug.gif?R=800x600). This information would be then written to a text file that I could look at to figure out what percentage of my users are using resolutions less than 1024x768. The returned image would be a blank 1x1 GIF. I don't want to use a third party hosted solution to do this tracking for me.

    According to http://TheCounter.com around 15% of users are still using 800x600. As I have a very high corporate and academic user base, what I'm hoping to find is that less than 5% of my user base uses 800x600 or smaller. If this is the case, I could change my site layout from 756px wide to 990px wide.

    There are some sections of my site that really need to go to a wider format than the 756px I currently have my pages locked to and having dynamic width pages is not an option. If I could go to a 980px wide format some usability issues I'm running into with new features I'm rolling out would go away.

    Forcing 15% of my users to horizontally scroll is not desirable, but once the percentage of my users still using something less than 1024x768 drops below 5% I feel that I can make the layout change I want.

    An example of the issue I am having is on http://environmentalchemistry.com/yo...chemicals.html, because of the necessary width of the "49CFR Hazardous Materials Table and the available width of my content area I have to cause the table to horizontally scroll. Restructuring the layout to eliminate the left hand ads and/or the right hand menu is not an option. Increasing the width of the page layout would allow me to increase the width of the content area by 200px, which would resolve the horizontal scrolling issue.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  2. #2
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    In my experience corporate & school usage is for LOWER resolutions, not higher resolutions. The reason is that when you're buying or replacing hundreds to thousands of monitors you tend to be more apt to cut costs by getting smaller ones.

    Or if your lab budget is limited you might go more years without upgrading.

    Thank being said, I believe the main thing in having php generate an image is having the appropriate header/mimetypes sent in the php file.

    Though you know, you can get resolution data with javascript based trackers like Google Analytics
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  3. #3
    Chronic Entrepreneur
    Join Date
    Nov 2003
    Location
    Tulsa, Oklahoma, USA
    Posts
    1,112
    I'm not sure why you want to bring an image into it. Couldn't you get the same result by just loading a php file in an invisible iframe? i.e., use javascript to generate the html to display getres.php?r=<resolution> in an invisible iframe, then have getres.php store the results in a file or db?

    Or, it might be possible to use some kind of clever ajax method to have your html page call a php script and send the user's resolution without using an iframe or image at all.

  4. #4
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    I was just thinking that an image tracker would be the cleanest way to do it and it would give me a chance to learn how to create images on the fly.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  5. #5
    Registered
    Join Date
    Aug 2006
    Location
    Sacramento, CA
    Posts
    208
    The simplest way as Chris stated would be to use Google Analytics, which gives tons of other useful data as well. I would recommend trying it out if you have never used it before.

    As far as using php to do it as you suggested, the easiest way is to simply redirect to a static image of your choice after the logging is complete using header() ie:

    PHP Code:
    header("Location: http://www.mysite.com/blankpixel.gif"); 
    If you wanted to show a dynamic image that changes based what you passed to the PHP script, it is a little more complicated and you would print out the actual image data along with the appropriate headers, but if you would just like to load a blank pixel the above is the easiest.
    ________
    Honda Sparta history
    Last edited by rpanella; 03-17-2011 at 10:25 AM.

  6. #6
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    Thanks, the header solution seems very simple for multiple purposes.

    I am giving Google Analytics a try. I mean it isn't like every page already has an AdSense ad on it so it isn't like I'm keeping any secrets from Google.

    I like the fact that Analytics can be tied into Google AdWords. This will help with conversion tracking on sites that I buy AdWords advertising for.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  7. #7
    Senior Member agua's Avatar
    Join Date
    Sep 2005
    Location
    Pottsville, NSW
    Posts
    531
    Ken - instantly you could give yourself 30 extra pixels by increasing your width to 785px (no horizontal scroll at 800x600).

    Then I would suggest using the css selectors: max-width (set at 990px) and min-width (set at 785px).

    I think you may have to do some work around in IE - but whats new there.

    This way you will have a semi flexible layout catering for all screen sizes with some control over the content display.
    I Do Website Design - but I am here to learn all about publishing

  8. #8
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    20px would do me no good. I need 200px. I also can't use any form of flexible styles like you suggest because of a host of cross browser issues especially with MSIE. As part of the SEO and accessibility design of the site the HTML code for the left hand column actually comes after the right hand menu HTML. The idea was for the important content to come first and all the detritus to come last if one was using a text only browser (take a look at my pages with CSS and JavaScript turned off).

    If the percentage of 800x600 users is low enough, I am considering setting my site to the wider width I want and then using JavaScript to narrow down my layout on computers with 800x600 resolution. This could be very tedious and tricky, but it might work. I simply want to provide as good of user experience as possible for the maximum percentage of users with accessibility being a top priority.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  9. #9
    Registered
    Join Date
    Aug 2006
    Location
    Sacramento, CA
    Posts
    208
    Ken, I had the same hesitation before using Google Analytics on one of my biggest sites, thinking that giving them all the data might be a bad idea. But as you say they already have plenty of ways to collect data from my website if they wanted to, since Adsense is on basically every page, not to mention toolbar users as well as a majority of my traffic comes from them in the first place.
    ________
    IOLITE VAPORIZER
    Last edited by rpanella; 03-17-2011 at 10:26 AM.

  10. #10
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    Quote Originally Posted by rpanella View Post
    Ken, I had the same hesitation before using Google Analytics on one of my biggest sites, thinking that giving them all the data might be a bad idea. But as you say they already have plenty of ways to collect data from my website if they wanted to, since Adsense is on basically every page, not to mention toolbar users as well as a majority of my traffic comes from them in the first place.
    Ya, Google probably already knows more about the traffic to my site than I do.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

Similar Threads

  1. Photoshop - How do I resize an image in a layer?
    By Erin in forum Graphics & Multimedia
    Replies: 8
    Last Post: 10-20-2014, 04:29 PM
  2. Review: Professional PHP Programming
    By Chris in forum Books
    Replies: 6
    Last Post: 07-17-2013, 05:26 AM
  3. Replies: 0
    Last Post: 08-17-2005, 03:39 PM
  4. Image Borders for CSS
    By Chris in forum HTML, CSS, Layout, and Design
    Replies: 8
    Last Post: 08-11-2005, 09:41 AM
  5. Replies: 0
    Last Post: 08-03-2005, 09:35 AM

Bookmarks

Posting Permissions

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