Skip to content

[4.x]: Inline image transforms - all file formats have the same file size #13512

Closed
@martin-coded

Description

@martin-coded

What happened?

Description

This is the first time I am using the built in inline image transforms to create different formats for an image. When doing this, the images are generated, but they all have the same file size. I tested this in two different hostings and my local dev environment, the result is always the same when using ImageMagick. I also tested other scenarios, but it seems that only the file extension is correct but the file ouput is always the same jpeg for avif and webp.

{% set hero_sources = [
  {type:'image/avif',  transform:{ mode: 'crop', width: 1920, height: 1400, format:'avif'}},
  {type:'image/webp',  transform:{ mode: 'crop', width: 1920, height: 1400, format:'webp'}},
  {type:'image/jpeg',  transform:{ mode: 'crop', width: 1920, height: 1400, format:'jpeg'}},
] %}
{% set hero_srcset = ['500w', '1000w', '1640w'] %}
{% set hero_sizes = '(max-width: 1023px) 100vw, 820px' %}

<picture>
  {% for source in hero_sources  %}
    <source srcset="{{image.getSrcset(hero_srcset,source.transform)}}" type="{{ source.type }}" sizes="{{ hero_sizes }}">
  {% endfor %}
  <img loading="lazy"  width="1920" height="1400"  srcset="{{image.getSrcset(hero_srcset)}}" class="">
</picture>

Steps to reproduce

  1. Copy the above code and check the file size of the created images.

Expected behavior

The images should have different file sizes. For example webp or avif should be way smaller than jpeg

Actual behavior

All created images have the same size.

Bildschirmfoto 2023-08-07 um 10 44 23

Craft CMS version

4.04

PHP version

8.2.8

Operating system and version

Linux 3.10.0-1160.88.1.el7.x86_64

Database type and version

MariaDB 10.6.12

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.0-54)

Installed plugins and versions

  • Craft CMS 4.4.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions