
GD_info를 사용하여 이미지 파일 크기를 가져올 수 있는 방법은 다음과 같습니다.
1. GD_info의 imageinfo() 함수를 사용하여 이미지 정보를 추출할 수 있습니다. 이 함수는 이미지의 크기, MIME 타입, 파일 이름, 파일 크기, 이미지 유형, 이미지 크기 등 다양한 정보를 반환합니다.
예시:
#hostingforum.kr
php
$image = imagecreatefromstring(file_get_contents('image.jpg'));
$info = getimagesizefromstring(file_get_contents('image.jpg'));
$width = $info[0];
$height = $info[1];
$file_size = $info[3];
echo "이미지 크기: $width x $heightn";
echo "파일 크기: $file_size bytesn";
2. GD_info의 imagecreatefromstring() 함수를 사용하여 이미지 파일을 로드한 후, getimagesize() 함수를 사용하여 이미지 크기를 가져올 수 있습니다.
예시:
#hostingforum.kr
php
$image = imagecreatefromstring(file_get_contents('image.jpg'));
$width = imagesx($image);
$height = imagesy($image);
$file_size = filesize('image.jpg');
echo "이미지 크기: $width x $heightn";
echo "파일 크기: $file_size bytesn";
3. GD_info의 imagecreatefromjpeg(), imagecreatefrompng(), imagecreatefromgif() 함수를 사용하여 이미지 파일을 로드한 후, getimagesize() 함수를 사용하여 이미지 크기를 가져올 수 있습니다.
예시:
#hostingforum.kr
php
$image = imagecreatefromjpeg('image.jpg');
$width = imagesx($image);
$height = imagesy($image);
$file_size = filesize('image.jpg');
echo "이미지 크기: $width x $heightn";
echo "파일 크기: $file_size bytesn";
이러한 방법 중 하나를 사용하여 이미지 파일 크기를 가져올 수 있습니다.
2025-08-04 19:41