Responsive Images Srcset and Sizes based on Image Transform
Merge operates on arrays or array-like things, and you probably handed it the string "card", which is why you got that error.

I think what you want to do here is use the transform in the control panel to define the aspect ratio, but use the img macro to determine which sizes to transform to.

You can calculate the aspect ratio like this:

{% set aspectRatio = asset.getHeight(options.style) / asset.getWidth(options.style) %}


And generate transforms like this:

transform|merge({width: width, height: width * aspectRatio})


You will want to be careful with the native (untransformed) image: only use it if it has the correct aspect ratio.

You will want to be careful with avoiding transforming to a larger image - skip the ones where the width would be greater than the native width and the ones where the height would be greater than the native height.

Using the crop transform instead of the stretch one (that the article uses) is the right thing to do too.

Also, consider the imager plugin, which has some useful srcset supporting features (and postdates that article)