adrian Posted March 5, 2013 Share Posted March 5, 2013 Not sure if this is expected behavior or not, but unless I set both dimensions during an $image->size, the upscaling option is ignored. Link to comment Share on other sites More sharing options...
ryan Posted March 6, 2013 Share Posted March 6, 2013 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 More sharing options...
adrian Posted March 6, 2013 Author Share Posted March 6, 2013 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 More sharing options...
Soma Posted March 9, 2013 Share Posted March 9, 2013 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 More sharing options...
adrian Posted March 9, 2013 Author Share Posted March 9, 2013 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); 1 Link to comment Share on other sites More sharing options...
doolak Posted March 31, 2013 Share Posted March 31, 2013 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 More sharing options...
doolak Posted March 31, 2013 Share Posted March 31, 2013 I found the information I was asking for: http://processwire.com/talk/topic/2287-image-size-configuration-questions/?p=22535 Maybe it would be fine to have all available options somewhere available at one place - the thread above would be a nice place to collect them ;-) 1 Link to comment Share on other sites More sharing options...
ryan Posted April 1, 2013 Share Posted April 1, 2013 Maybe it would be fine to have all available options somewhere available at one place - the thread above would be a nice place to collect them ;-) Here you go (I just added this page now): http://processwire.com/api/fieldtypes/images/ 4 Link to comment Share on other sites More sharing options...
apeisa Posted April 1, 2013 Share Posted April 1, 2013 Great stuff Ryan. Great idea with "related forum threads". 1 Link to comment Share on other sites More sharing options...
ceberlin Posted November 14, 2013 Share Posted November 14, 2013 Note: small typo in the post above: if($page->image->width() < 500) {...} should be: if($page->image->width < 500) {...} right? Link to comment Share on other sites More sharing options...
ryan Posted November 16, 2013 Share Posted November 16, 2013 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. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now