Re: KEEP IMAGE RATIO

From: Date: Wed, 16 Jul 2003 17:41:59 +0000
Subject: Re: KEEP IMAGE RATIO
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-155470@lists.php.net to get a copy of this message
And I still don't see how your proposed method handles the problem you mentioned above with Image2... RDB
Now, first, what would you prefer? Second, I hope you understand how the new feature would address the issue (and that you know what the issue is - if i explained it clearly, of course) As sent to www-talk@w3c.org (please read in total, some stuff added) ---------------------------------------------------------------------- consider: Image1 : 100x100 (Ratio = 1:1) Image2 : 100x200 (Ratio = 1:2) Space available for display : 75x75 now, i can say "width=75% height=75%", but this will only work for Image1, since Image2 will end up as 75x150 (which clearly does not fit the 75x75 constraints) now, if i specify "width=75 height=75", again, this works for Image1, but not Image2, since the new Image2 ratio will be 1:1, with Image2 losing 1/2 of it's heigth ratio. Rather, with "img width=75 height=75 ratio=keep", we will have the following results: Final Display: Image1 : 75x75 : (RATIO 1x1) Image2 : 38x75 (37.5x75) : (RATIO 1:2) This is something simple enough for the browser to handle, and I think it should. ------------------------------------------------------------------------------------- Now, as far as not seeing how this helps, keep in mind that this is NOT a feature, but SHOULD, and a reponse I got from www-talk@w3c.org is the following: ========================================================= this is what I use to maintain aspect ratio and constrain the image to the limits I have if($image_path == "") {
       $relative_directory = "/images/logo.gif";
       $size = @GetImageSize(getenv("DOCUMENT_ROOT").$relative_directory);
} else {
       $relative_directory = "/images/gallery/$sportid/";
       $size = @GetImageSize(getenv("DOCUMENT_ROOT").$relative_directory."/".$image_path);
} $width = $size[0]; $height = $size[1]; if($width > 500) {
       if(($width > 500)&&($height > 400))
       {
           $width2 = ($size[0] - ( $size[0] * (1 - (500/$size[0]))));
           $height2 = ($size[1] -  ( $size[1] *  (1 - (400/$size[1]))));
       }
       else
       {
           $width2 = ($size[0] - ( $size[0] * (1 - (500/$size[0]))));
           $height2 = $size[1];
       }
} else {
       $width2 = $size[0];
       $height2 = $size[1];
} ========================================================

« previous php.general (#155470) next »