Guest User

Untitled

a guest
Oct 22nd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. // With fixed size:
  4. $square_size = 300;
  5. $curr_width = $_GET['width'];
  6. $curr_height = $_GET['height'];
  7.  
  8. if ($curr_width === $curr_height) {
  9. $width = $height = $square_size;
  10. } else if (($height = ($curr_height / $curr_width) * $square_size) >= $square_size) {
  11. $width = $square_size;
  12. } else if (($width = ($curr_width / $curr_height) * $square_size) >= $square_size) {
  13. $height = $square_size;
  14. }
  15.  
  16. printf('<div style="overflow:hidden; width:%1$upx; height:%1$upx;"><img src="image.jpg" style="width:%2$upx; height:%3$upx;"></div>', $square_size, $width, $height);
Advertisement
Add Comment
Please, Sign In to add comment