【发布时间】:2015-06-12 13:15:38
【问题描述】:
我有以下 php 和 imagick 脚本来动态调整图像大小:
调整大小.php
$_size = $_GET['size'];
$_path = $_GET['path'];
$img = new Imagick($_path);
$img_d = $img->getImageGeometry();
$img_w = $img_d['width'];
$img_h = $img_d['height'];
..// more variables
$crop_w = round($_size * $p_w);
$crop_h = round($_size * $p_h);
list($_w, $_h) = scaleProportions($crop_w, $crop_h, $img_w, $img_h);
$img->resizeImage($_w, $_h, imagick::FILTER_LANCZOS, 0);
header("Content-Type: image/jpg");
header("Cache-control: Public");
$headerTimeOffset = 60 * 60 * 24 * 30;
$headeExpire = "Expires: ".gmdate("D, d M Y H:i:s",time()+$headerTimeOffset)." GMT";
header ($headeExpire);
$img->setImageFormat('jpg');
$img->setImageCompression(Imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality($_quality);
echo $img->getImageBlob();
我在我的 img 标签中这样称呼这个脚本:
images.html
<img src="http:www.mysite.com/resize/size/path" alt="xxxx">
这按预期工作。我现在不仅需要获得新调整大小的图像,还需要获得新调整大小的尺寸。这有可能吗?
这样做的原因是我在每个图像上使用了 masonry 插件和延迟加载,并希望在它们加载之前设置网格。我知道在图像加载之前砌体需要这些尺寸
【问题讨论】:
标签: php imagick dimensions masonry