I think it could be usefull to have a resize function, that can take only the target width OR target height and culculates the other dimension itself.

This way, we would be able to create images for example with the same width but different heights from source images with mixed proportions. Or a portrait and a lanscape format get the same height.

CommentFileSizeAuthor
#8 imagecache_scale.patch877 bytesquicksketch

Comments

quicksketch’s picture

This functionality already exists. Use 'scale' instead of resize and only specify one parameter.

alanburke’s picture

Ok The suggestion of scaling on one size doesn't work for me..

But I did spy a workaround.

Imagcache scale will scale such that the lower value of height or width is respected.

SO...to scale to a standard width of say 300px, set scale width to 300px, but set height to something very high, eg 3000.

[Unless you have images that are VERY high and thin, this should work]

I'd be interested to see whether this works for you.

Regards
Alan

suit4’s picture

Title: Resize on one dimesion only » Ecactly what I am looking for

Very cool, this is, what I was looking for.

This is some kind of hidden functionality. THat shoul be mentioned as a helping text or so, or implemented as a real feature.
E.g. if someone leaves the height field empty in scale or resize, that the other values is sent to the scale function.

And: I agree, image cache is very usefull.

scroogie’s picture

Title: Ecactly what I am looking for » Resize on one dimesion only
fangius’s picture

Without your workaround passing only one parameter still barfs with latest version imagecache-HEAD.tar.gz dated November 11, 2006 - 09:14.
Should really work as #3 suggested (intuitive).
Your workaround is still holding. Nice find!

quicksketch’s picture

I'm working on implementing this functionality today (resize on one dimension, the other not required).

quicksketch’s picture

Assigned: Unassigned » quicksketch
quicksketch’s picture

Status: Active » Needs review
StatusFileSize
new877 bytes

This patch simply passes in ridiculously high values to the scale function if height or width are not defined, allowing image_scale to use the smaller (defined value). Patch should apply to 4-7, 5, and HEAD branches.

dopry’s picture

Status: Needs review » Fixed

I applies it to all 3 branches... Hopefully it works. ;).

Anonymous’s picture

Status: Fixed » Closed (fixed)