@@ -270,6 +270,54 @@ public function output($image_type = null, $quality = null)
270270 $ this ->save (null , $ image_type , $ quality );
271271 }
272272
273+ /**
274+ * Resizes image according to the given short side (short side proportional)
275+ *
276+ * @param integer $max_short
277+ * @param boolean $allow_enlarge
278+ * @return \static
279+ */
280+ public function resizeToShortSide ($ max_short , $ allow_enlarge = false )
281+ {
282+ if ($ this ->getSourceHeight () < $ this ->getSourceWidth ()) {
283+ $ ratio = $ height / $ this ->getSourceHeight ();
284+ $ width = $ this ->getSourceWidth () * $ ratio ;
285+
286+ $ this ->resize ($ width , $ height , $ allow_enlarge );
287+ } else {
288+ $ ratio = $ height / $ this ->getSourceWidth ();
289+ $ width = $ this ->getSourceHeight () * $ ratio ;
290+
291+ $ this ->resize ($ width , $ height , $ allow_enlarge );
292+ }
293+
294+ return $ this ;
295+ }
296+
297+ /**
298+ * Resizes image according to the given long side (short side proportional)
299+ *
300+ * @param integer $max_long
301+ * @param boolean $allow_enlarge
302+ * @return \static
303+ */
304+ public function resizeToLongSide ($ max_long , $ allow_enlarge = false )
305+ {
306+ if ($ this ->getSourceHeight () > $ this ->getSourceWidth ()) {
307+ $ ratio = $ height / $ this ->getSourceHeight ();
308+ $ width = $ this ->getSourceWidth () * $ ratio ;
309+
310+ $ this ->resize ($ width , $ height , $ allow_enlarge );
311+ } else {
312+ $ ratio = $ height / $ this ->getSourceWidth ();
313+ $ width = $ this ->getSourceHeight () * $ ratio ;
314+
315+ $ this ->resize ($ width , $ height , $ allow_enlarge );
316+ }
317+
318+ return $ this ;
319+ }
320+
273321 /**
274322 * Resizes image according to the given height (width proportional)
275323 *
0 commit comments