#1 January 15, 2016 2:27pm

jesse.glaves
Member
Registered: June 28, 2014
Posts: 124

Image Crop Horizontal or Vertical

I'm trying to build a module that can process photos of various sizes and orientation. I wanted to use the crops in the Upload field options to make a few different sizes (thumb, mid, large), but I'm not seeing a way to deal with photos when the orientation is unknown (may be vertical or horizontal). I'm probably overlooking a simple solution, but any help is appreciated. Thanks.

Offline

#2 January 15, 2016 2:31pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Image Crop Horizontal or Vertical

If you're going to end up with two different crop sets (different dimensions for the portrait and landscape images) you'll need to put together a custom field type. The draw file can just include the default upload field type's draw file. In the process file you'd need to do a getimagesize call on the uploaded image to figure out what type it is and then swap in a different set of crops into $field["options"]["crops"] and then you could include upload.php's process file to handle the rest.

Offline

#3 January 15, 2016 2:31pm

jesse.glaves
Member
Registered: June 28, 2014
Posts: 124

Re: Image Crop Horizontal or Vertical

Also, I guess I don't really want to crop now that I think of it. I'm interested in resizing the images. If the width is greater than the height, then scale it to a certain width, retaining the aspect ratio, and for images that are taller than they are wide, scale based on height.

Offline

#4 January 15, 2016 2:32pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Image Crop Horizontal or Vertical

I'd proceed the same way with just swapping out $field["options"]["thumbs"] instead of crops smile

Offline

#5 January 15, 2016 2:34pm

jesse.glaves
Member
Registered: June 28, 2014
Posts: 124

Re: Image Crop Horizontal or Vertical

Thanks Tim. I'll see what I can do. Probably sounds more difficult than it actually is smile

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.