我有以下磁贴值:
$tileheight = "58"; // 100x100 104px 560x560
$tileheight = "36"; // 200x200 104px 560x560
$tileheight = "32"; // 300x300 104px 560х560
$tileheight = "30"; // 400x400 104px 560х560
100x100 ... 400x400 - 图块内生成图像的高度和宽度
104px - 瓷砖高度
560x560 - 始终输出的高度和宽度(适合图像)
价值是什么 - "?"尺寸500x500?我可以使用什么公式?
$tileheight = "?"; // 500x500 104px 560х560
更新:
这是我用于转换的代码:
exec("convert '$image' -resize ".$imgw."x".$imgh."! -quality 100 'proc/res$session.jpg'");
exec("convert '$tile' -resize x".$tileheight." -quality 100 'proc/til$session.jpg'");
exec("convert $image $pp -write mpr:image +delete \
proc/til$session.jpg -write mpr:edge_top +delete \
proc/til$session.jpg -write mpr:edge_btm +delete \
\
mpr:image -alpha set -bordercolor none \
-compose Dst -frame ".$tileheight."x".$tileheight."+".$tileheight." -compose over \
\
-transverse -tile mpr:edge_btm \
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
-transverse -tile mpr:edge_top \
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
\
mpr:image -gravity center -composite proc/ok$session.jpg");
$input = "proc/ok$session.jpg";
$toWidth = "840";
$toHeight = "560";
$quality = "100";
// -background white -gravity center -extent {$toWidth}x{$toHeight}
exec("convert $input -thumbnail {$toWidth}x{$toHeight} proc/ok$session.jpg");
这里我使用什么公式来制作正确的瓷砖高度:
$tiledata = getimagesize($tile);
$tilewidth = $tiledata[0];
$tileheight = $tiledata[1];
$math1 = ($tileheight+$tileheight)/($imgw+$imgh);
$tileheight = $tileheight * $math1;
答案 0 :(得分:1)
在调整大小之前已将帧添加到图像中。
您的图像宽度为400像素,帧数为30像素:
400+2*30 = 460
要调整大小,您必须乘以560/460
,为您提供样本jpeg中的输出:具有36px大帧的488x488图像。 (36 * 2 + 488 = 560)
因此,您必须考虑使用的值是错误的,因为您没有获得400x400图像。但是使用正确的值非常困难,因为瓷砖只有104px大,宽度低于352px是不可能的。
您还必须考虑使用与框架的新图层匹配的坐标,以便在美学上可以接受。
大于352像素的图像的正确公式将类似于:
$tileHeight = (560 - $expectedWidth) / 2;
编辑: 从原始网站的示例中,框架宽度和高度在最终调整大小为560px之前保持不变。
你无需计算!
## first we resize the original image to the size wanted
exec("convert '$image' -resize ".$imgw."x".$imgh."! -quality 100 'proc/res$session.jpg'");
## we add the frame edge by using the original width and size of the "$tile" file
$tiledata = getimagesize($tile);
$tilewidth = $tiledata[0];
$tileheight = $tiledata[1];
exec("convert 'proc/res$session.jpg' -write mpr:image +delete \
'$tile' -write mpr:edge_top +delete \
'$tile' -write mpr:edge_btm +delete \
\
mpr:image -alpha set -bordercolor none \
-compose Dst -frame ".$tileheight."x".$tileheight."+".$tileheight." -compose over \
\
-transverse -tile mpr:edge_btm \
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
-transverse -tile mpr:edge_top \
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
\
mpr:image -gravity center -composite proc/ok$session.jpg");
## and we resize to the desired final output size
$input = "proc/ok$session.jpg";
$toWidth = "840";
$toHeight = "560";
$quality = "100";
// -background white -gravity center -extent {$toWidth}x{$toHeight}
exec("convert $input -thumbnail {$toWidth}x{$toHeight} proc/ok$session.jpg");