Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Request - image resize depending on client display settings

    Hi to you all,
    I'm new to this forum and i don't know if this is discussed before but I have a request for a script.

    Is it possible to collect the client display settings (width and height) at full screen and send this to the server. A PHP script then must process these values to resize an image acording to those values (serverside). The Javascript must then show the resized image full screen on the client computer.

    The PHP script i use is:
    Code:
    <?php 
    
    function imageresize($width, $height, $target) { 
    
    
    if ($width > $height) { 
    $percentage = ($target / $width); 
    } else { 
    $percentage = ($target / $height); 
    } 
    
    //gets the new value and applies the percentage, then rounds the value 
    $width = round($width * $percentage); 
    $height = round($height * $percentage); 
    return "width=\"$width\" height=\"$height\""; 
    } 
    
    
    //get the image size of the picture and load it into an array 
    $mysock = getimagesize("playa_del_ingles_big.jpg"); 
    
    ?> 
    
    <img src="playa_del_ingles_big.jpg" <?php print (imageresize($mysock[0], $mysock[1], 150)); ?>>
    How can i do that and pass the values to the script?

    Thanks in advance,

    Wietze

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What does client screen size have to do with the size of the browser clent window???
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Quote Originally Posted by Vladdy
    What does client screen size have to do with the size of the browser clent window???
    I have a big collection of large images (3000x2000 pixels) on my server and want them to be shown at the client computer in a way they don't have to scroll. The (resized) image must be fit in the client (maximized) browser window.

    Wietze

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow JS to PHP

    you want a script to detect screen size then. this would then populate some hidden fields. when the user clicks a link to the page with the images, you append these values to the query string. then in you PHP app, you use $HTTP_GET_VARS to pull them out. having done this, you can code your app to resize the images accordingly before displaying them to the user.

  • #5
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Jbot,

    Can you please post an example? This would be very helpful to me.

    Wietze

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by wvisscher
    Hi,



    I have a big collection of large images (3000x2000 pixels) on my server and want them to be shown at the client computer in a way they don't have to scroll. The (resized) image must be fit in the client (maximized) browser window.

    Wietze
    How do you know that the client window is maximized?
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #7
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Vladdy,

    Quote Originally Posted by Vladdy
    How do you know that the client window is maximized?
    I don't know, but I think there must be a way determine the maximum available size (current display settings of the client). So I can open a new maximized window from JS.

    Wietze

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by wvisscher
    Hi Vladdy,



    I don't know, but I think there must be a way determine the maximum available size (current display settings of the client). So I can open a new maximized window from JS.

    Wietze
    First, how do you know that JS is available.
    Second, even if it is, real browsers won't let you manipulate window size (plus pop-up blockers won't let you open new windows)

    If you want to make it user friendly, initialy load small thumbnails. Next to each thumbnail have a list of links to images of preset resolutions:
    Code:
     
    |------------------|
    |                  |   640x480
    |     Thumbnail    |   800x600
    |                  |   1200x800
    |------------------|
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"


  •  

    Posting Permissions

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