Php 确定瓷砖大小顺序

Php 确定瓷砖大小顺序,php,image,math,imagemagick,sequence,Php,Image,Math,Imagemagick,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-瓷砖高度 560x56

我有以下平铺值:

$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中的输出:一幅36px大帧的488x488图像。(36*2+488=560)

<>所以,你必须考虑使用的值是错误的,因为你没有获得一个400×400的图像。但是使用正确的值是非常困难的,因为瓷砖只有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");

没有足够的信息!我想我们需要看看你的命令。但是,在获得正确的输出图像尺寸560x560之前,您是否可以尝试图像大小为500x500的各种tileheight值?也许我不明白您是如何在命令中使用瓷砖高度的。能否提供ImageMagick命令行来处理图像以添加瓷砖?续:如果内部图像为NxN,瓷砖厚度为m,则输出图像将始终为(N+2m)x(N+2m),前提是您没有在内部图像和瓷砖之间或瓷砖外部添加任何恒定边界。因此,我不明白如何获得100x100的内部图像,瓷砖厚度为58,以获得560x560大小的图像。您必须调整内部图像的大小。你在这么做吗?此外,您说您的瓷砖厚度始终为104,但您的瓷砖高度参数要小得多,并且该值的两倍不是104。那么你在做什么呢?你到底想做什么?在一张随机大小的图像上添加一帧?如果是这样的话,这里有一个方法:以及在Imagemagick论坛上的讨论。在我看来,在没有看到输入图像和瓷砖的情况下,您需要将输入图像的大小调整为小于2*的大小,在每个维度上进行瓷砖大小调整,然后添加具有所需瓷砖大小的瓷砖。您能否发布一个带有平铺的示例输入图像以及所需的平铺大小输出。@kostya572这些示例肯定是我们在您的问题中遗漏的:输出的内部图像没有预期的大小。此尺寸用于首先使用其原始尺寸应用框架,然后将其最终调整为560px。@Adam谢谢,你指导我正确使用瓷砖。问题还在于,这个网站将内部图像放大了大约2.4倍,这就是为什么我找不到正确的比例。我不知道他们为什么要扩大规模。可能不会丢失图像质量输出或获得更具吸引力的输出。