PHP圖片裁剪之擷取圖片大小getimagesize

來源:互聯網
上載者:User

在網上下了一個圖片裁剪的外掛程式jquery.cropzoom.min.js,功能非常的強大,而且還幫我準備了一個php的動態指令碼,不費多少功夫就搭好了。而且跑起來挺不錯的。裁剪+旋轉圖片,一鍵即可。

 

一開始沒什麼問題,後來修改時,就出現了一個莫名的錯誤。詳細的描述如下:

 

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Warning: getimagesize(http://localhost/cms/uploadfiles/2010/08/24/133934.jpg) [function.getimagesize]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in D:/AppServ/www/cms/test/test.php on line 3

Fatal error: Maximum execution time of 30 seconds exceeded in D:/AppServ/www/cms/test/test.php on line 3

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

 

看到這個錯誤,我就想是不是getimagesize需要伺服器配置什麼,因為在家裡是行的,我立刻debug了一下:

<?php $size =getimagesize("http://localhost/cms/uploadfiles/2010/08/24/133934.jpg"); var_dump($size); ?> 

結果顯示挺正常的

X-Powered-By: PHP/5.2.10 ZendServer

Set-Cookie: ZendDebuggerCookie=127.0.0.1%3A10137%3A0||084|77742D65|1003; path=/

Content-type: text/html

 

array(7) {

  [0]=>

  int(800)

  [1]=>

  int(533)

  [2]=>

  int(2)

  [3]=>

  string(24) "width="800" height="533""

  ["bits"]=>

  int(8)

  ["channels"]=>

  int(3)

  ["mime"]=>

  string(10) "image/jpeg"

} 然後直接在apache上跑了一下這代碼(web),就出現了同樣的問題了。 這麼看來,應該是跟伺服器相關了。後來懷著揣測的心態,把http://localhost/cms/uploadfiles/2010/08/24/133934.jpg改成了相對位址../../uploadfiles/2010/08/24/133934.jpg 嘿,還真行了。看來它是把圖片當遠程載入了,不知道getimagesize的工作原理,所以也無從猜測。 但是如果是這樣,那php怎麼能直接直接擷取remote photo的大小。。 求解。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.