Resize Images Centered And Scaled

See all posts Reply

Resize Images Centered And Scaled new!
by Erik Greif, 9 years, 9 months ago
When I set my upload like this:
if (($handle->image_src_x) > 1024 or ($handle->image_src_y) > 1024) {
  $handle->image_resize   = true;
  $handle->image_y        = 1024;
  $handle->image_x        = 1024;
  $handle->image_ratio    = true;
}
$handle->file_new_name_body = $_title;
$handle->image_convert      = 'jpg';

On an image with a greater width than height the rendered 'thumbnail' is cropped from the left of the photo. So portraits are off center. How do I force this to grab the cropped image from the center of the scaled image?Reply
Re: Resize Images Centered And Scaled new!
by Erik Greif, 9 years, 9 months ago
Oh my god I'm SUCH an idiot. IGNORE that code above please, I copied it from the wrong thing -_-

THIS code please:
$handle->file_new_name_body   = $_title;
$handle->image_resize         = true;
$handle->image_x              = 128;
$handle->image_y              = 128;
$handle->image_ratio_crop     = 'L';
$handle->image_convert        = 'jpg';
Reply
Re: Resize Images Centered And Scaled new!
by colin, 9 years, 9 months ago
Read the docs for image_ratio_crop. Your code explicitly set it as L, which keeps the left-most part of the image of cropping. Just set it to true in order to get the center.Reply
Re: Resize Images Centered And Scaled new!
by Erik Greif, 9 years, 9 months ago
Oh... I just poorly assumed that it could be L or W for cropping length or width to match the ratio. Woops.Reply