确定图块大小顺序

Determine tile size sequence

我有以下图块值:

$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

此处显示 400x400 的输出结果:

更新:

这是我用于转换的代码:

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;

框架已添加到调整大小之前的图像。

您有一张 400 像素宽、30 像素边框的图像:

 400+2*30 = 460

要调整大小,您必须乘以 560/460,从而得到样本 jpeg 中的输出:一张 488x488 的图像和 36px 的大框架。 (36*2 + 488 = 560)

因此,您必须考虑使用的值是错误的,因为您没有获得 400x400 的图像。但是很难使用正确的值,因为图块只有 104px 大,宽度小于 352px 是不可能的。

您还必须考虑是否应该使用与框架的新层相匹配的坐标,以便在美学上可以接受。

大于 352px 的图像的正确公式如下:

 $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");