简体   繁体   中英

getimagesize returns nulls for PNG images despite allow_url_fopen=1

I use list($pws,$phs,$pfts,$pfas)=getimagesize($row->picurl); on correctly linked pictures which display fine, but some are too wide to fit in the table column.

ini_get('allow_url_fopen') returns 1 .

According to the manual, getimagesize() doesn't require the GD Image Library.

phpversion() returns "5.3.9-1~dotdeb.3" .

What I want to do is compare the width of external PNG image urls to a table column width while filling the table, to scale only incorrectly uploaded huge ones and keep the other correct ones unscaled, ie. either set width="384" for the img tag, or not.

Most PNGs are exported from Photoshop with the Save For Web option, rgb 24-bits, no alpha or matte, so they should be as good as they get, yet even those return nulls.

Do I need to enable something else on the server or can I check the width with some other function?

I will also accept any comparable solutions to achieve this.

If you know the width of the column, you can set CSS max-width on the image:

<img src="..." style="max-width: <?= $column_width; ?>;" />

This will reduce large images but not enlarge smaller images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM