Skip to main content

joeri poesen / bio / blog / contact

Home / Articles / Drupal + imagecache + Invalid image dimensions error?

Imagecache was dutifully scaling images without any problems, when suddenly this error started popping up:

warning: imagecreatetruecolor() [function.imagecreatetruecolor]: 
Invalid image dimensions [...]

It started when I added an extra action to one of my imachecache presets: after scaling to a fixed width, I wanted to crop to a fixed height while keeping the previously attained width.

To scale to a fixed width, you need to enter the target width and keep the height blank. Quite straightforward. No problem.

However, to crop, you need to enter both target width and target height, even when one of them is to remain unchanged.

So, lesson boys and girls: always enter width and height when defining a crop action in imagecache.