php获取图像尺寸大小的方法,Javascript从php生成的图像中获取图像大小
我發現此代碼可以在
javascript上獲取圖像大小:
function getImgSize(imgSrc)
{
var newImg = new Image();
newImg.src = imgSrc;
var height = newImg.height;
var width = newImg.width;
alert ('The image size is '+width+'*'+height);
}
它工作得很好,但我需要獲得受保護的圖像的大小;為了訪問圖像,我使用頁面image.php?id = IMAGE_ID,它工作,因為在這個頁面我檢查權限并發回圖像.但是當我把這個鏈接放在javascript函數上時,為了獲得它的大小,它不起作用.任何幫助(如果我把圖像的直接鏈接既不起作用,因為它在.htaccess文件中被阻止)?
包含圖像的文件夾還包含一個.htaccess文件,該文件拒絕訪問以進行翻轉.要獲取圖像,我使用此PHP頁面:
Image.php:
//check if the user has permission
//if not, show a image with the text 'no permission'
//if it's ok
$filename = "images\\fotos\\" . $imgl;
$image = imagecreatefromjpeg($filename);
header('Content-type: image/jpeg');
imagejpeg($image, null, 100);
imagedestroy($image);
總結
以上是生活随笔為你收集整理的php获取图像尺寸大小的方法,Javascript从php生成的图像中获取图像大小的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php导出excel表格需要隐藏行,ph
- 下一篇: 计算机php什么意思,我们所说的计算机一