Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // With fixed size:
- $square_size = 300;
- $curr_width = $_GET['width'];
- $curr_height = $_GET['height'];
- if ($curr_width === $curr_height) {
- $width = $height = $square_size;
- } else if (($height = ($curr_height / $curr_width) * $square_size) >= $square_size) {
- $width = $square_size;
- } else if (($width = ($curr_width / $curr_height) * $square_size) >= $square_size) {
- $height = $square_size;
- }
- 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