简体   繁体   English

Typo3流体图像裁剪与高度错误

[英]Typo3 Fluid Image crop of with and height failure

Using this code: 使用此代码:

<f:image src="/uploads/extkey/{image}" alt="" width="115c" height="70c" />

Produces following HTML output: 产生以下HTML输出:

<img src="typo3temp/_processed_/csm_testimage_31f6051846.gif" width="115" height="92" alt="">

图片标签的屏幕截图

The image has a wrong height now and there are white bars at top and bottom. 图像的高度现在有误,顶部和底部都有白色条。 I figured out that "92" comes from its proportion (original image is: 1280 × 1024). 我发现“ 92”来自其比例(原始图像为:1280×1024)。 I guess if the white bars at top and bottom are cut out the height of 70 will be reached. 我想如果将顶部和底部的白条切掉,将达到70的高度。 Any ideas why Typo3 is doing that wrong and does some others here having the same problem? 有任何想法为什么Typo3做错了吗,这里的其他一些人也有同样的问题吗?

Using Typo3 6.1.5 ImageMagick 6 使用Typo3 6.1.5 ImageMagick 6

EDIT #2: Tried different combinations with width,height,crop,maxWidth,maxHeight like: 编辑#2:尝试使用width,height,crop,maxWidth,maxHeight的不同组合,例如:

<f:image src="/uploads/extkey/{image}" alt="" width="115" height="70c" maxHeight="70" />

The results/fails are: 结果/失败是:

  • Image is not 115x70 图片不是115x70
  • Image is deformed 影像变形

I have found the correct solution for this Bug. 我已找到此错误的正确解决方案。 Its now more then 4 years old and still not fixed. 现在已经超过4年,但仍未修复。 The file and the line has changed to: /typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php , Line: 2315 文件和行已更改为:/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php,行:2315

http://forge.typo3.org/issues/19045 http://forge.typo3.org/issues/19045

t3lib/class.t3lib_stdgraphic.php line 2181 (in version 4.2.6 that is) t3lib / class.t3lib_stdgraphic.php第2181行(在版本4.2.6中)

adapt line to $params .= ' -crop '.$data['origW'].'x'.$data['origH'].'+'.$offsetX.'+'.$offsetY.'! 使行适应$ params。='-crop'。$ data ['origW']。'x'。$ data ['origH']。'+'。$ offsetX。'+'。$ offsetY。'! '; ';

I just added the "!" 我刚刚添加了“!” at the end and it now works - "!" 最后,现在可以使用-“!” after the crop command tells imagemagick to adjust canvas and viewport. 裁剪命令告诉imagemagick调整画布和视口后。

Didn't test this with any other installations than the one I'm working on right now (4.2.6 with IM 6.3.7), so somebody should probably do this before this fix is commited into core. 除了我现在正在使用的安装(IM 6.3.7的4.2.6)以外,没有在其他安装上进行过测试,因此在将此修补程序提交到内核之前,可能应该有人进行此操作。

The c after the dimension means "crop scaling". 尺寸后的c表示“裁剪比例”。 You cannot crop-scale for both width and height at the same time. 您不能同时对宽度和高度进行缩放。 So you should maybe set a fixed width (width="115") and then crop-scale the height (height="70c"). 因此,您可能应该设置一个固定的宽度(width =“ 115”),然后裁剪缩放高度(height =“ 70c”)。 This way the image will be resized to width 115 pixel and every pixel that it's higher than 70 pixels will be cropped. 这样,图像将被调整为115像素的宽度,并且高于70像素的每个像素都会被裁剪。

@ggzone: As I already commented, please try doing the same thing with a TypoScript object, meaning: Create an IMAGE cObject with the same parameters and output it on the page. @ggzone:正如我已经评论过的,请尝试使用TypoScript对象执行相同的操作,这意味着:创建具有相同参数的IMAGE cObject并将其输出到页面上。 If it doesn't work either, it's a problem of TYPO3 or ImageMagick, if it works, it's a Fluid problem. 如果两者都不起作用,则可能是TYPO3或ImageMagick的问题,如果有效,则是Fluid问题。 We need to narrow your problem. 我们需要解决您的问题。

You should use maxWidth and maxHeight to specify an box in which the image should be fit 您应该使用maxWidthmaxHeight指定一个适合图像的框

ie

<f:image src="/uploads/extkey/{image}" alt="" maxWidth="115c" maxHeight="70c" />

Params for IM are maxW , maxH not maxHeight, seems they are the same in typo3. IM的参数是maxWmaxH而不是maxHeight,似乎它们在typo3中是相同的。
may be this will work: 可能这将工作:

<f:image src="/uploads/extkey/{image}" alt="" maxH="70c"  maxW="115c" />

Edit: 编辑:

What is the size of your original image ? 您原始图像的大小是多少?

'c' is used for crop and if your original is smaller or in other proportions ... 'c'用于农作物,并且如果您的原件较小或其他比例...

Try use the 'm' param for Max value ? 尝试使用“ m”参数获取最大值?

<f:image src="/uploads/extkey/{image}" alt="" width="115m" height="70"   />

reference: TYPO3 TS reference 参考: TYPO3 TS参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM