getimagesize()를 사용하여 jpg, gif, png 또는 다른 유형의 이미지를 검사하는 PHP 코드를 어떻게 만들 수 있는지 궁금합니다.PHP를 사용하여 이미지 크기 조정 질문이 있으십니까?
그런 다음 이미지 CSS의 폭이 다음 CSS 코드의 너비보다 작은 지 확인하십시오. 그렇다면 PHP 코드는 가로 또는 세로의 이미지 종횡비를 유지하면서 이미지의 크기를 다시 조정해야합니다. .
나는 그것이 getimagesize()를 사용하는 것 같지만는 이미지 크기 다시하지 않는 것보다 코드의이 작품은 온라인으로 나열 발견
overflow: hidden; width:100px; height: auto;
CSS 코드입니다. 이 문제를 해결할 수있는 방법이 있습니까?
<?php
function imageResize($width, $height, $target) {
//takes the larger size of the width and height and applies the
//formula accordingly...this is so this script will work
//dynamically with any size image
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);
//returns the new sizes in html image tag format...this is so you
//can plug this function inside an image tag and just get the
return "width=\"$width\" height=\"$height\"";
}
?>
<?php
//get the image size of the picture and load it into an array
$mysock = getimagesize("images/sock001.jpg");
?>
<!--using a standard html image tag, where you would have the
width and height, insert your new imageResize() function with
the correct attributes -->
<img src="images/sock001.jpg" <?php imageResize($mysock[0],
$mysock[1], 150); ?>>
그렇게 다시하지 않을 경우 이미지 폭이 100 픽셀보다 작은 경우 확인하고 참조하는 방법을 내가 할 수있는 알고 -크기. – seeu
죄송합니다. – seeu
영화 * 줌과 같이 작동하는 경우에만! 높이다! z 방향으로 90도 회전! * – alex