Due to imagecache's use of the drupal image_scale function, it does not upscale images smaller than the selected dimensions on the imagecache presets page.

This is very confusing when you are trying to scale up an image to 'outside' dimensions and then crop it to a fixed size -- depending on the input images, it can appear as if that imagecache is scaling to inside dimensions, etc etc.

Adding this note on the download page or in the README will be very useful to developers not familar with drupal and has the potential to save some developers a lot of time! Thanks!

CommentFileSizeAuthor
#3 imagecache_15.patch2 KBnicholasthompson

Comments

nicholasthompson’s picture

Title: Please add a note that imagecache will NOT upscale images smaller than the scaled dimensions. » ImageCache needs its own image_scale function to allows image upscaling
Version: 5.x-1.3 » 5.x-1.x-dev
Component: Documentation » Code
Status: Active » Needs work

I attach a patch which allows imagecache to also up-scale images.

Its basically a copy of the image_scale function from image.inc with a few lines removed to allow it to up-scale.

Some people prefer images to NOT up-scale... So maybe this patch needs revising to allow a switch/override?

Please review and revise! :-)

ragaskar’s picture

thanks, I upgraded to HEAD and it pretty much fixed all my issues. ;)

nicholasthompson’s picture

StatusFileSize
new2 KB

Seems the patch didn't attach last time... Which is odd!

Here is the patch (I HOPE)

ms2011’s picture

+1 for imagecache upscaling.
Confirm patch works.
Thanks nicholasThompson! :)

dopry’s picture

I'm not sure if I wouldn't rather add a transparent border instead of upscaling and madly distorting the image....

What say you pros and cons?

nicholasthompson’s picture

I agree that upscaling and distorting images is not always ideal. It might be best, for example, to allow a parameter to be set to determine what happens to an image which is set to be scaled to a size larger than its default...
1) No upscale
2) Upscale regardless
3) Return image of required size with appropriate padding around it

For option 3 one might also want a parameter to determine the colour of the padding. This adds extra and, in my opinion, unnecessary complication.

I think it would suffice to simply have upscaling as an option.

I found it useful to be able to upscale a small avatar to a size which fits neatly into a specified area on, for example, a profile page. If the user then does not like the blocky avatar they always have the option to upload and overwrite with a new avatar as larger ones will scale down nicely whereas smaller will not scale up nicely.

dopry’s picture

Status: Needs work » Fixed

This is in HEAD.... there is an upscale flag on the scale action.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.