//$wOverflow = $widthAtFullHeight - $o_width; //$hOverflow = $heightAtFullWidth - $o_height; echo "widthAtFullHeight: {$widthAtFullHeight}\n"; echo "heightAtFullWidth: {$heightAtFullWidth}\n"; //echo "wOverflow: $wOverflow\n"; //echo "hOverflow: $hOverflow\n"; switch ($sizeType) { case 'contain': if ($widthAtFullHeight <= $s_width) { $size['width'] = $widthAtFullHeight; $size['height'] = $s_height; } else { $size['height'] = $heightAtFullWidth; $size['width'] = $s_width; } break; case 'cover': if ($widthAtFullHeight >= $s_width) { $size['width'] = $widthAtFullHeight; $size['height'] = $s_height; } else { $size['height'] = $heightAtFullWidth; $size['width'] = $s_width; } break; } // end switch sizetype return $size; } var_dump(dahlen_image_get_image_size('cover', 800, 500, 200, 300));
function dahlen_image_zenphoto_to_slideshow_image($zenphotoImage, $SlideshowID, $slideshowType, $slideshowWidth, $slideshowHeight) { $s_width = intval($slideshowWidth); $s_height = intval($slideshowHeight); $dims = dahlen_image_get_image_size('contain-bigger', $s_width, $s_height, intval($zenphotoImage['width']), intval($zenphotoImage['height'])); return array_merge($zenphotoImage, array('SlideshowID' => $SlideshowID, 'ZenphotoID' => $zenphotoImage['id'], 'OffsetX' => intval(($s_width - $dims['width']) / 2), 'OffsetY' => intval(($s_height - $dims['height']) / 2), 'DurationBeforeHiding' => $slideshowType === 'still' ? 1000 : 250, 'NextImageDelay' => $slideshowType === 'still' ? 1000 : 225, 'TransitionIn' => "'fade'", 'TransitionOut' => "'fade'", 'TransitionInDuration' => $slideshowType === 'still' ? 500 : 100, 'TransitionOutDuration' => $slideshowType === 'still' ? 500 : 100)); }