Jump to content

upscaling=>false not working when one dimension set to 0


adrian
 Share

Recommended Posts

Thanks for letting me know. I'll take a look at this. Though specifying "0" for either dimension means "keep it proportional", and that would take precedence. What were the original and target dimensions of the image you were seeing get upscaled?

Link to comment
Share on other sites

Ryan,

My goal in this case is to make sure that the images being displayed are go greater than 500px wide. I don't care about the height, so I set it to '0'. What I want to make sure is that no image gets upscaled to 500 if its actual dimensions are less, which I think in most cases would be default behavior due to the quality issues associated with upscaling. One of the test images I uploaded with 175px (w) by 297px (h) and it was upscaled to 500px. Setting things to 500,500 seemed to take care of things. I assumed that the values were maximum dimensions for each, rather than crop, but I get the feeling now that maybe this is not the case. I have been using SLIR for image resizing for several years and I am used to that behavior. Is that approach possible with PW - ie to set both dimensions as max for the respective dimension, rather than assuming a crop. Does that make sense?

Link to comment
Share on other sites

You could always test for the width and if smaller don't do a size().

if($page->image->width() < 500) {
    $img = $page->image->url;
} else {
    $img = $page->image->size(500,0)->url;
} 

Also have you tried doing a

$page->image->width(500); 
 

Does it also upscale?

However I think it should be taken care by the size itself.

Link to comment
Share on other sites

Hi Soma - thanks, checking for the original size of the image is definitely an option. I do think though that the upscaling=>false option should work with one dimension set to 0. However, this also seems to work:

$options = array('upscaling'=>false,'cropping'=>false,'quality'=>90);
$image->size(500,'',$options);
 

As does this, which is maybe the most logical option:

$options = array('upscaling'=>false,'cropping'=>false,'quality'=>90);
$image->width(500,$options);
 
  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

What is the current status of the availabe options for resizing an image? Can I find some information about this somewhere?

I usually use e.g.:

$detail = $project->project_image->size(800, 600, array('upscaling' => false, 'cropping' => true));
$thumb = $project->project_image->size(250, 175, array('upscaling' => false, 'cropping' => true));

Is there any option now available to set cropping to center or top?

Edit: Ahh, forgot to mention: HAPPY EASTERN !!! ;-)

Link to comment
Share on other sites

  • 7 months later...

It doesn't matter. Either width() or width can be used in that scenario. When using the non-function version, $page->image->width then you are just retrieving the width. When using the function version you can retrieve or set set the width. 

$width = $page->image->width; // get the width
$width = $page->image->width(); // get the width, same
$thumb = $page->image->width(100); // get image having width 100

Same goes for the height. 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...