使用 image 或 graphmagick 自动进行图像缩放

发布于 2024-11-19 03:05:56 字数 111 浏览 4 评论 0原文

我有一个取决于 imagemagick 的问题: 是否可以仅上传一张高度为 1200 像素的图片,并根据设备或浏览器分辨率减小图像的图像高度尺寸?

提前致谢

I've got a question that depends on imagemagick:
Is it possible to upload just one picture with a size of 1200px height for example and -depending on device or browser resolution- reduce the imageheight AND size of the image?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罗罗贝儿 2024-11-26 03:05:56

您可以根据设备或浏览器版本使用条件。假设您想在以下图像高度之间切换:

  • IE6 为 600px,
  • 移动设备为 320px,
  • 所有其他设备为 800px
    (即普通计算机)

然后将此部分输入到您的模板常量

# for IE6:
[browser = msie] AND [version = 6]
styles.content.imgtext {
        maxH = 600
        maxHInText = 600
}
# for mobile devices:
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]||[useragent = *OperaMini*]||[useragent = *BlackBerry*]
styles.content.imgtext {
        maxH = 320
        maxHInText = 320
}
# For all other browsers
[else]
styles.content.imgtext {
        maxH = 800
        maxHInText = 800
}
[GLOBAL]

模板设置的替代解决方案(如下所述):

# for IE6:
[browser = msie] AND [version = 6]
tt_content.image.20.1.file {
        maxH = 600
        maxHInText = 600
}
# for mobile devices:
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]||[useragent = *OperaMini*]||[useragent = *BlackBerry*]
tt_content.image.20.1.file {
        maxH = 320
        maxHInText = 320
}
# For all other browsers
[else]
tt_content.image.20.1.file {
        maxH = 800
        maxHInText = 800
}
[GLOBAL]
  1. 这些只是条件的一些示例。查看 TYPO3 条件
    参考
    以获取更多想法。
  2. 如果 useragent 无法正确识别移动设备,请尝试扩展 cwmobileredirect。它提供了非常可靠的移动设备切换。
  3. 这是关于如何设置图像高度。我听说设置宽度 (maxW) 工作正常,但设置高度 (maxH) 在 4.2 以下的版本中不知何故有问题。如果 maxH 出现问题,请使用替代解决方案。

You can use conditions depending on devices or browser versions. Assuming you like to switch between the folling image heights:

  • 600px for IE6,
  • 320px for mobile devices,
  • 800px for all other devices
    (i.e. regular computers)

Then enter this section to your template constants:

# for IE6:
[browser = msie] AND [version = 6]
styles.content.imgtext {
        maxH = 600
        maxHInText = 600
}
# for mobile devices:
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]||[useragent = *OperaMini*]||[useragent = *BlackBerry*]
styles.content.imgtext {
        maxH = 320
        maxHInText = 320
}
# For all other browsers
[else]
styles.content.imgtext {
        maxH = 800
        maxHInText = 800
}
[GLOBAL]

Alternative solution for template setup (explained below):

# for IE6:
[browser = msie] AND [version = 6]
tt_content.image.20.1.file {
        maxH = 600
        maxHInText = 600
}
# for mobile devices:
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]||[useragent = *OperaMini*]||[useragent = *BlackBerry*]
tt_content.image.20.1.file {
        maxH = 320
        maxHInText = 320
}
# For all other browsers
[else]
tt_content.image.20.1.file {
        maxH = 800
        maxHInText = 800
}
[GLOBAL]
  1. These are just some examples of conditions. Check out the TYPO3 conditions
    reference
    for more ideas.
  2. If the recognition of mobile devices does not work correctly with useragent, try the extension cwmobileredirect. It provides a very reliable mobile device switch.
  3. This is about how to set the image height. I heard rumours that setting the width (maxW) works fine, but setting the height (maxH) is buggy somehow in versions below 4.2. Use the alternative solution if problems with maxH occur.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文