Developer forum

Forum » Feature requests » Image handler - resize when image too small

Image handler - resize when image too small

Nuno Aguiar
Reply

Hi,

 

Some time ago there was some talk about managing the background color when an image was too small for the image handler dimensions, for example a 50px by 50px image with settings to 200px by 200px. If this was implemented was great.

 

Another even more important feature, when the image is too small, is to respect the crop offset. Using the same example as above, no matter if the crop is 0, 1, 2, 3 or 4, the original image is always on the top left. If that value could be kept, for example Crop=0, the image would be in the center.

 

Nuno


Replies

 
Nicolai Høeg Pedersen
Reply

If the image is too small, it is not resized up.

 

You can place an image inside a div with your desired width/height and set a background color on that one. If the image is too small, it will simply inherit the background color from the div.

 

BR Nicolai

 
Nuno Aguiar
Reply

Hi Nicolai,

 

Of course I would not assign a smaller image to it consciously knowing it. The problem happens when:

  • clients do it
  • remaking website designs, sometimes the old content is smaller than the new one

Having no control over the abose situations, div and alignments and background colors (in the div) are not a solution :(

 

Nuno

 
Nuno Aguiar
Reply

Hi Nicolai,

 

I wasn't very explicit on one part. The image handler does resize the image, hence the problem. I tried it with the attached image and the following settings:

 

/Admin/Public/GetImage.aspx?Image=/Files/Billeder/smallSquare.gif&Format=jpg&Width=200&Height=200

 

I do get a 200 by 200 image response

 

Nuno

smallSquare.gif
 
Morten Bengtson
Reply

For paragraph images you can use if statements on ParagraphImageWidth and ParagraphImageHeight, which contains the original dimensions of the image. This way you can check the original dimensions of the image and display the image any way you want to.

 

How common is this problem? Maybe if the client was instructed to only add images with certain minimum dimensions this would not happen? Displaying a very small image with a background color taking up the remaining space will look even weirder than an image that has been scaled up. If the client for some reason needs to be able to add tiny images this can be done using a rich text field?

 

 
Nuno Aguiar
Reply

Hi Morten,

 

It's starting to become a problem because of old clients that want a refresh image on the website.

 

We have one with over 1400 news, and we implemented the website before the image handler existed. This is a governamental organization, so they have to keep an archive. Migrating to the new design, loading the categories results in this problem, hence the feature request.

 

Nuno

 
Morten Bengtson
Reply

Maybe you could use an if statement on the news date and handle images on old news articles differently. Another option is to link to a separate page displaying the historic news archive.

 
Nuno Aguiar
Reply

Hi Morten,

 

Thanks for the suggestions. However if the image handler at least did not resize if the image is smaller, passing a new parameter for example &resizeIfSmaller=false would help prevent issues.

 

Nuno