我在使用MicroFormats时遇到问题,并确定要使用哪种itemtype,无论是Product还是Offer.我使用Offer将数据添加到我们销售的各种产品中(每页1个).虽然这在Google结构化数据测试工具中正确验证,但它不会在结果中显示价格/评级/ InStock.如果我使用Product和Offer的混合物,那么虽然我不确定这是正确的方法吗?
谢谢,
干草堆
<title>My Tent</title>
<div itemscope itemtype="http://schema.org/Offer">
<div itemprop="name" class="product-details-title" id="item_product_prop">My Tent</div>
<div itemprop="description" id="item_product_prop">A Description for MyTent</div>
<meta itemprop="aggregateRating" id="item_product_prop" content="[3 Ratings]">
<div id="item_product_prop" itemprop="price">$13</div>
<div itemprop="availability" id="item_product_prop" content="InStock"></div></div>
</div>
Run Code Online (Sandbox Code Playgroud)
http://www.google.com/webmasters/tools/richsnippets?q=uploaded:8004e1c78c1098daa7aa283c26b42939
我正在尝试在 iMagick 中执行以下操作,但无法使其正常工作:
检查图像是否超过 390 像素高,如果是,则将其调整为 390 像素高,如果不是保持尺寸。
添加一个白色画布,宽 300 像素,高 400 像素,然后将图像放在画布的中心。
我的代码是:
$im = new Imagick("test.jpg");
$imageprops = $im->getImageGeometry();
$width = $imageprops['width'];
$height = $imageprops['height'];
if($height > '390'){
$newHeight = 390;
$newWidth = (390 / $height) * $width;
}else{
$newWidth = $imageprops['width'];
$newHeight = $imageprops['height'];
}
$im->resizeImage($newWidth,$newHeight, Imagick::FILTER_LANCZOS, 0.9, true);
$canvas = new Imagick();
$canvas->newImage(300, 400, 'white', 'jpg');
$canvas->compositeImage($im, Imagick::COMPOSITE_OVER, 100, 50);
$canvas->writeImage( "test-1.jpg" );
Run Code Online (Sandbox Code Playgroud)
生成图像时,由于某种原因,大图像被缩放到 388 像素高,小图像保留其原始尺寸。
尽管在将 100,50 添加到合成图像的大图像上确实有效,但在画布上的放置始终是不正确的。
大多数图像都是又高又瘦,但也有一些比高度更宽。
我哪里出错了?
谢谢,
瑞克